
obj/user/testpipe.debug:     file format elf32-i386


Disassembly of section .text:

00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
	// See if we were started with arguments on the stack
	cmpl $USTACKTOP, %esp
  800020:	81 fc 00 e0 bf ee    	cmp    $0xeebfe000,%esp
	jne args_exist
  800026:	75 04                	jne    80002c <args_exist>

	// If not, push dummy argc/argv arguments.
	// This happens when we are loaded by the kernel,
	// because the kernel does not know about passing arguments.
	pushl $0
  800028:	6a 00                	push   $0x0
	pushl $0
  80002a:	6a 00                	push   $0x0

0080002c <args_exist>:

args_exist:
	call libmain
  80002c:	e8 a5 02 00 00       	call   8002d6 <libmain>
1:	jmp 1b
  800031:	eb fe                	jmp    800031 <args_exist+0x5>

00800033 <umain>:

char *msg = "Now is the time for all good men to come to the aid of their party.";

void
umain(int argc, char **argv)
{
  800033:	f3 0f 1e fb          	endbr32 
  800037:	55                   	push   %ebp
  800038:	89 e5                	mov    %esp,%ebp
  80003a:	56                   	push   %esi
  80003b:	53                   	push   %ebx
  80003c:	83 ec 7c             	sub    $0x7c,%esp
	char buf[100];
	int i, pid, p[2];

	binaryname = "pipereadeof";
  80003f:	c7 05 04 30 80 00 a0 	movl   $0x8025a0,0x803004
  800046:	25 80 00 

	if ((i = pipe(p)) < 0)
  800049:	8d 45 8c             	lea    -0x74(%ebp),%eax
  80004c:	50                   	push   %eax
  80004d:	e8 75 1d 00 00       	call   801dc7 <pipe>
  800052:	89 c6                	mov    %eax,%esi
  800054:	83 c4 10             	add    $0x10,%esp
  800057:	85 c0                	test   %eax,%eax
  800059:	0f 88 1b 01 00 00    	js     80017a <umain+0x147>
		panic("pipe: %e", i);

	if ((pid = fork()) < 0)
  80005f:	e8 1d 11 00 00       	call   801181 <fork>
  800064:	89 c3                	mov    %eax,%ebx
  800066:	85 c0                	test   %eax,%eax
  800068:	0f 88 1e 01 00 00    	js     80018c <umain+0x159>
		panic("fork: %e", i);

	if (pid == 0) {
  80006e:	0f 85 56 01 00 00    	jne    8001ca <umain+0x197>
		cprintf("[%08x] pipereadeof close %d\n", thisenv->env_id, p[1]);
  800074:	a1 04 40 80 00       	mov    0x804004,%eax
  800079:	8b 40 48             	mov    0x48(%eax),%eax
  80007c:	83 ec 04             	sub    $0x4,%esp
  80007f:	ff 75 90             	pushl  -0x70(%ebp)
  800082:	50                   	push   %eax
  800083:	68 ce 25 80 00       	push   $0x8025ce
  800088:	e8 a2 03 00 00       	call   80042f <cprintf>
		close(p[1]);
  80008d:	83 c4 04             	add    $0x4,%esp
  800090:	ff 75 90             	pushl  -0x70(%ebp)
  800093:	e8 c2 14 00 00       	call   80155a <close>
		cprintf("[%08x] pipereadeof readn %d\n", thisenv->env_id, p[0]);
  800098:	a1 04 40 80 00       	mov    0x804004,%eax
  80009d:	8b 40 48             	mov    0x48(%eax),%eax
  8000a0:	83 c4 0c             	add    $0xc,%esp
  8000a3:	ff 75 8c             	pushl  -0x74(%ebp)
  8000a6:	50                   	push   %eax
  8000a7:	68 eb 25 80 00       	push   $0x8025eb
  8000ac:	e8 7e 03 00 00       	call   80042f <cprintf>
		i = readn(p[0], buf, sizeof buf-1);
  8000b1:	83 c4 0c             	add    $0xc,%esp
  8000b4:	6a 63                	push   $0x63
  8000b6:	8d 45 94             	lea    -0x6c(%ebp),%eax
  8000b9:	50                   	push   %eax
  8000ba:	ff 75 8c             	pushl  -0x74(%ebp)
  8000bd:	e8 6d 16 00 00       	call   80172f <readn>
  8000c2:	89 c6                	mov    %eax,%esi
		if (i < 0)
  8000c4:	83 c4 10             	add    $0x10,%esp
  8000c7:	85 c0                	test   %eax,%eax
  8000c9:	0f 88 cf 00 00 00    	js     80019e <umain+0x16b>
			panic("read: %e", i);
		buf[i] = 0;
  8000cf:	c6 44 05 94 00       	movb   $0x0,-0x6c(%ebp,%eax,1)
		if (strcmp(buf, msg) == 0)
  8000d4:	83 ec 08             	sub    $0x8,%esp
  8000d7:	ff 35 00 30 80 00    	pushl  0x803000
  8000dd:	8d 45 94             	lea    -0x6c(%ebp),%eax
  8000e0:	50                   	push   %eax
  8000e1:	e8 e1 09 00 00       	call   800ac7 <strcmp>
  8000e6:	83 c4 10             	add    $0x10,%esp
  8000e9:	85 c0                	test   %eax,%eax
  8000eb:	0f 85 bf 00 00 00    	jne    8001b0 <umain+0x17d>
			cprintf("\npipe read closed properly\n");
  8000f1:	83 ec 0c             	sub    $0xc,%esp
  8000f4:	68 11 26 80 00       	push   $0x802611
  8000f9:	e8 31 03 00 00       	call   80042f <cprintf>
  8000fe:	83 c4 10             	add    $0x10,%esp
		else
			cprintf("\ngot %d bytes: %s\n", i, buf);
		exit();
  800101:	e8 24 02 00 00       	call   80032a <exit>
		cprintf("[%08x] pipereadeof write %d\n", thisenv->env_id, p[1]);
		if ((i = write(p[1], msg, strlen(msg))) != strlen(msg))
			panic("write: %e", i);
		close(p[1]);
	}
	wait(pid);
  800106:	83 ec 0c             	sub    $0xc,%esp
  800109:	53                   	push   %ebx
  80010a:	e8 3d 1e 00 00       	call   801f4c <wait>

	binaryname = "pipewriteeof";
  80010f:	c7 05 04 30 80 00 67 	movl   $0x802667,0x803004
  800116:	26 80 00 
	if ((i = pipe(p)) < 0)
  800119:	8d 45 8c             	lea    -0x74(%ebp),%eax
  80011c:	89 04 24             	mov    %eax,(%esp)
  80011f:	e8 a3 1c 00 00       	call   801dc7 <pipe>
  800124:	89 c6                	mov    %eax,%esi
  800126:	83 c4 10             	add    $0x10,%esp
  800129:	85 c0                	test   %eax,%eax
  80012b:	0f 88 32 01 00 00    	js     800263 <umain+0x230>
		panic("pipe: %e", i);

	if ((pid = fork()) < 0)
  800131:	e8 4b 10 00 00       	call   801181 <fork>
  800136:	89 c3                	mov    %eax,%ebx
  800138:	85 c0                	test   %eax,%eax
  80013a:	0f 88 35 01 00 00    	js     800275 <umain+0x242>
		panic("fork: %e", i);

	if (pid == 0) {
  800140:	0f 84 41 01 00 00    	je     800287 <umain+0x254>
				break;
		}
		cprintf("\npipe write closed properly\n");
		exit();
	}
	close(p[0]);
  800146:	83 ec 0c             	sub    $0xc,%esp
  800149:	ff 75 8c             	pushl  -0x74(%ebp)
  80014c:	e8 09 14 00 00       	call   80155a <close>
	close(p[1]);
  800151:	83 c4 04             	add    $0x4,%esp
  800154:	ff 75 90             	pushl  -0x70(%ebp)
  800157:	e8 fe 13 00 00       	call   80155a <close>
	wait(pid);
  80015c:	89 1c 24             	mov    %ebx,(%esp)
  80015f:	e8 e8 1d 00 00       	call   801f4c <wait>

	cprintf("pipe tests passed\n");
  800164:	c7 04 24 95 26 80 00 	movl   $0x802695,(%esp)
  80016b:	e8 bf 02 00 00       	call   80042f <cprintf>
}
  800170:	83 c4 10             	add    $0x10,%esp
  800173:	8d 65 f8             	lea    -0x8(%ebp),%esp
  800176:	5b                   	pop    %ebx
  800177:	5e                   	pop    %esi
  800178:	5d                   	pop    %ebp
  800179:	c3                   	ret    
		panic("pipe: %e", i);
  80017a:	50                   	push   %eax
  80017b:	68 ac 25 80 00       	push   $0x8025ac
  800180:	6a 0e                	push   $0xe
  800182:	68 b5 25 80 00       	push   $0x8025b5
  800187:	e8 bc 01 00 00       	call   800348 <_panic>
		panic("fork: %e", i);
  80018c:	56                   	push   %esi
  80018d:	68 c5 25 80 00       	push   $0x8025c5
  800192:	6a 11                	push   $0x11
  800194:	68 b5 25 80 00       	push   $0x8025b5
  800199:	e8 aa 01 00 00       	call   800348 <_panic>
			panic("read: %e", i);
  80019e:	50                   	push   %eax
  80019f:	68 08 26 80 00       	push   $0x802608
  8001a4:	6a 19                	push   $0x19
  8001a6:	68 b5 25 80 00       	push   $0x8025b5
  8001ab:	e8 98 01 00 00       	call   800348 <_panic>
			cprintf("\ngot %d bytes: %s\n", i, buf);
  8001b0:	83 ec 04             	sub    $0x4,%esp
  8001b3:	8d 45 94             	lea    -0x6c(%ebp),%eax
  8001b6:	50                   	push   %eax
  8001b7:	56                   	push   %esi
  8001b8:	68 2d 26 80 00       	push   $0x80262d
  8001bd:	e8 6d 02 00 00       	call   80042f <cprintf>
  8001c2:	83 c4 10             	add    $0x10,%esp
  8001c5:	e9 37 ff ff ff       	jmp    800101 <umain+0xce>
		cprintf("[%08x] pipereadeof close %d\n", thisenv->env_id, p[0]);
  8001ca:	a1 04 40 80 00       	mov    0x804004,%eax
  8001cf:	8b 40 48             	mov    0x48(%eax),%eax
  8001d2:	83 ec 04             	sub    $0x4,%esp
  8001d5:	ff 75 8c             	pushl  -0x74(%ebp)
  8001d8:	50                   	push   %eax
  8001d9:	68 ce 25 80 00       	push   $0x8025ce
  8001de:	e8 4c 02 00 00       	call   80042f <cprintf>
		close(p[0]);
  8001e3:	83 c4 04             	add    $0x4,%esp
  8001e6:	ff 75 8c             	pushl  -0x74(%ebp)
  8001e9:	e8 6c 13 00 00       	call   80155a <close>
		cprintf("[%08x] pipereadeof write %d\n", thisenv->env_id, p[1]);
  8001ee:	a1 04 40 80 00       	mov    0x804004,%eax
  8001f3:	8b 40 48             	mov    0x48(%eax),%eax
  8001f6:	83 c4 0c             	add    $0xc,%esp
  8001f9:	ff 75 90             	pushl  -0x70(%ebp)
  8001fc:	50                   	push   %eax
  8001fd:	68 40 26 80 00       	push   $0x802640
  800202:	e8 28 02 00 00       	call   80042f <cprintf>
		if ((i = write(p[1], msg, strlen(msg))) != strlen(msg))
  800207:	83 c4 04             	add    $0x4,%esp
  80020a:	ff 35 00 30 80 00    	pushl  0x803000
  800210:	e8 b0 07 00 00       	call   8009c5 <strlen>
  800215:	83 c4 0c             	add    $0xc,%esp
  800218:	50                   	push   %eax
  800219:	ff 35 00 30 80 00    	pushl  0x803000
  80021f:	ff 75 90             	pushl  -0x70(%ebp)
  800222:	e8 53 15 00 00       	call   80177a <write>
  800227:	89 c6                	mov    %eax,%esi
  800229:	83 c4 04             	add    $0x4,%esp
  80022c:	ff 35 00 30 80 00    	pushl  0x803000
  800232:	e8 8e 07 00 00       	call   8009c5 <strlen>
  800237:	83 c4 10             	add    $0x10,%esp
  80023a:	39 f0                	cmp    %esi,%eax
  80023c:	75 13                	jne    800251 <umain+0x21e>
		close(p[1]);
  80023e:	83 ec 0c             	sub    $0xc,%esp
  800241:	ff 75 90             	pushl  -0x70(%ebp)
  800244:	e8 11 13 00 00       	call   80155a <close>
  800249:	83 c4 10             	add    $0x10,%esp
  80024c:	e9 b5 fe ff ff       	jmp    800106 <umain+0xd3>
			panic("write: %e", i);
  800251:	56                   	push   %esi
  800252:	68 5d 26 80 00       	push   $0x80265d
  800257:	6a 25                	push   $0x25
  800259:	68 b5 25 80 00       	push   $0x8025b5
  80025e:	e8 e5 00 00 00       	call   800348 <_panic>
		panic("pipe: %e", i);
  800263:	50                   	push   %eax
  800264:	68 ac 25 80 00       	push   $0x8025ac
  800269:	6a 2c                	push   $0x2c
  80026b:	68 b5 25 80 00       	push   $0x8025b5
  800270:	e8 d3 00 00 00       	call   800348 <_panic>
		panic("fork: %e", i);
  800275:	56                   	push   %esi
  800276:	68 c5 25 80 00       	push   $0x8025c5
  80027b:	6a 2f                	push   $0x2f
  80027d:	68 b5 25 80 00       	push   $0x8025b5
  800282:	e8 c1 00 00 00       	call   800348 <_panic>
		close(p[0]);
  800287:	83 ec 0c             	sub    $0xc,%esp
  80028a:	ff 75 8c             	pushl  -0x74(%ebp)
  80028d:	e8 c8 12 00 00       	call   80155a <close>
  800292:	83 c4 10             	add    $0x10,%esp
			cprintf(".");
  800295:	83 ec 0c             	sub    $0xc,%esp
  800298:	68 74 26 80 00       	push   $0x802674
  80029d:	e8 8d 01 00 00       	call   80042f <cprintf>
			if (write(p[1], "x", 1) != 1)
  8002a2:	83 c4 0c             	add    $0xc,%esp
  8002a5:	6a 01                	push   $0x1
  8002a7:	68 76 26 80 00       	push   $0x802676
  8002ac:	ff 75 90             	pushl  -0x70(%ebp)
  8002af:	e8 c6 14 00 00       	call   80177a <write>
  8002b4:	83 c4 10             	add    $0x10,%esp
  8002b7:	83 f8 01             	cmp    $0x1,%eax
  8002ba:	74 d9                	je     800295 <umain+0x262>
		cprintf("\npipe write closed properly\n");
  8002bc:	83 ec 0c             	sub    $0xc,%esp
  8002bf:	68 78 26 80 00       	push   $0x802678
  8002c4:	e8 66 01 00 00       	call   80042f <cprintf>
		exit();
  8002c9:	e8 5c 00 00 00       	call   80032a <exit>
  8002ce:	83 c4 10             	add    $0x10,%esp
  8002d1:	e9 70 fe ff ff       	jmp    800146 <umain+0x113>

008002d6 <libmain>:
const volatile struct Env *thisenv;
const char *binaryname = "<unknown>";

void
libmain(int argc, char **argv)
{
  8002d6:	f3 0f 1e fb          	endbr32 
  8002da:	55                   	push   %ebp
  8002db:	89 e5                	mov    %esp,%ebp
  8002dd:	56                   	push   %esi
  8002de:	53                   	push   %ebx
  8002df:	8b 5d 08             	mov    0x8(%ebp),%ebx
  8002e2:	8b 75 0c             	mov    0xc(%ebp),%esi
	;    //系统调用，我们已经在Exercise 7中实现了
	
	
	
	//屏幕上打印出来了字母，但后续报错了，有意思，让我看看问题出现在哪。
	thisenv=0;
  8002e5:	c7 05 04 40 80 00 00 	movl   $0x0,0x804004
  8002ec:	00 00 00 
	thisenv = &envs[ENVX(sys_getenvid())];      //获取Env结构指针
  8002ef:	e8 10 0b 00 00       	call   800e04 <sys_getenvid>
  8002f4:	25 ff 03 00 00       	and    $0x3ff,%eax
  8002f9:	6b c0 7c             	imul   $0x7c,%eax,%eax
  8002fc:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  800301:	a3 04 40 80 00       	mov    %eax,0x804004

	// save the name of the program so that panic() can use it
	if (argc > 0)
  800306:	85 db                	test   %ebx,%ebx
  800308:	7e 07                	jle    800311 <libmain+0x3b>
		binaryname = argv[0];
  80030a:	8b 06                	mov    (%esi),%eax
  80030c:	a3 04 30 80 00       	mov    %eax,0x803004

	// call user main routine
	umain(argc, argv);
  800311:	83 ec 08             	sub    $0x8,%esp
  800314:	56                   	push   %esi
  800315:	53                   	push   %ebx
  800316:	e8 18 fd ff ff       	call   800033 <umain>

	// exit gracefully
	exit();
  80031b:	e8 0a 00 00 00       	call   80032a <exit>
}
  800320:	83 c4 10             	add    $0x10,%esp
  800323:	8d 65 f8             	lea    -0x8(%ebp),%esp
  800326:	5b                   	pop    %ebx
  800327:	5e                   	pop    %esi
  800328:	5d                   	pop    %ebp
  800329:	c3                   	ret    

0080032a <exit>:

#include <inc/lib.h>

void
exit(void)
{
  80032a:	f3 0f 1e fb          	endbr32 
  80032e:	55                   	push   %ebp
  80032f:	89 e5                	mov    %esp,%ebp
  800331:	83 ec 08             	sub    $0x8,%esp
	close_all();
  800334:	e8 52 12 00 00       	call   80158b <close_all>
	sys_env_destroy(0);
  800339:	83 ec 0c             	sub    $0xc,%esp
  80033c:	6a 00                	push   $0x0
  80033e:	e8 7c 0a 00 00       	call   800dbf <sys_env_destroy>
}
  800343:	83 c4 10             	add    $0x10,%esp
  800346:	c9                   	leave  
  800347:	c3                   	ret    

00800348 <_panic>:
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt, ...)
{
  800348:	f3 0f 1e fb          	endbr32 
  80034c:	55                   	push   %ebp
  80034d:	89 e5                	mov    %esp,%ebp
  80034f:	56                   	push   %esi
  800350:	53                   	push   %ebx
	va_list ap;

	va_start(ap, fmt);
  800351:	8d 5d 14             	lea    0x14(%ebp),%ebx

	// Print the panic message
	cprintf("[%08x] user panic in %s at %s:%d: ",
  800354:	8b 35 04 30 80 00    	mov    0x803004,%esi
  80035a:	e8 a5 0a 00 00       	call   800e04 <sys_getenvid>
  80035f:	83 ec 0c             	sub    $0xc,%esp
  800362:	ff 75 0c             	pushl  0xc(%ebp)
  800365:	ff 75 08             	pushl  0x8(%ebp)
  800368:	56                   	push   %esi
  800369:	50                   	push   %eax
  80036a:	68 f8 26 80 00       	push   $0x8026f8
  80036f:	e8 bb 00 00 00       	call   80042f <cprintf>
		sys_getenvid(), binaryname, file, line);
	vcprintf(fmt, ap);
  800374:	83 c4 18             	add    $0x18,%esp
  800377:	53                   	push   %ebx
  800378:	ff 75 10             	pushl  0x10(%ebp)
  80037b:	e8 5a 00 00 00       	call   8003da <vcprintf>
	cprintf("\n");
  800380:	c7 04 24 e9 25 80 00 	movl   $0x8025e9,(%esp)
  800387:	e8 a3 00 00 00       	call   80042f <cprintf>
  80038c:	83 c4 10             	add    $0x10,%esp

	// Cause a breakpoint exception
	while (1)
		asm volatile("int3");
  80038f:	cc                   	int3   
  800390:	eb fd                	jmp    80038f <_panic+0x47>

00800392 <putch>:
};


static void
putch(int ch, struct printbuf *b)
{
  800392:	f3 0f 1e fb          	endbr32 
  800396:	55                   	push   %ebp
  800397:	89 e5                	mov    %esp,%ebp
  800399:	53                   	push   %ebx
  80039a:	83 ec 04             	sub    $0x4,%esp
  80039d:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  8003a0:	8b 13                	mov    (%ebx),%edx
  8003a2:	8d 42 01             	lea    0x1(%edx),%eax
  8003a5:	89 03                	mov    %eax,(%ebx)
  8003a7:	8b 4d 08             	mov    0x8(%ebp),%ecx
  8003aa:	88 4c 13 08          	mov    %cl,0x8(%ebx,%edx,1)
	if (b->idx == 256-1) {
  8003ae:	3d ff 00 00 00       	cmp    $0xff,%eax
  8003b3:	74 09                	je     8003be <putch+0x2c>
		sys_cputs(b->buf, b->idx);
		b->idx = 0;
	}
	b->cnt++;
  8003b5:	83 43 04 01          	addl   $0x1,0x4(%ebx)
}
  8003b9:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  8003bc:	c9                   	leave  
  8003bd:	c3                   	ret    
		sys_cputs(b->buf, b->idx);
  8003be:	83 ec 08             	sub    $0x8,%esp
  8003c1:	68 ff 00 00 00       	push   $0xff
  8003c6:	8d 43 08             	lea    0x8(%ebx),%eax
  8003c9:	50                   	push   %eax
  8003ca:	e8 ab 09 00 00       	call   800d7a <sys_cputs>
		b->idx = 0;
  8003cf:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  8003d5:	83 c4 10             	add    $0x10,%esp
  8003d8:	eb db                	jmp    8003b5 <putch+0x23>

008003da <vcprintf>:

int
vcprintf(const char *fmt, va_list ap)
{
  8003da:	f3 0f 1e fb          	endbr32 
  8003de:	55                   	push   %ebp
  8003df:	89 e5                	mov    %esp,%ebp
  8003e1:	81 ec 18 01 00 00    	sub    $0x118,%esp
	struct printbuf b;

	b.idx = 0;
  8003e7:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  8003ee:	00 00 00 
	b.cnt = 0;
  8003f1:	c7 85 f4 fe ff ff 00 	movl   $0x0,-0x10c(%ebp)
  8003f8:	00 00 00 
	vprintfmt((void*)putch, &b, fmt, ap);
  8003fb:	ff 75 0c             	pushl  0xc(%ebp)
  8003fe:	ff 75 08             	pushl  0x8(%ebp)
  800401:	8d 85 f0 fe ff ff    	lea    -0x110(%ebp),%eax
  800407:	50                   	push   %eax
  800408:	68 92 03 80 00       	push   $0x800392
  80040d:	e8 20 01 00 00       	call   800532 <vprintfmt>
	sys_cputs(b.buf, b.idx);
  800412:	83 c4 08             	add    $0x8,%esp
  800415:	ff b5 f0 fe ff ff    	pushl  -0x110(%ebp)
  80041b:	8d 85 f8 fe ff ff    	lea    -0x108(%ebp),%eax
  800421:	50                   	push   %eax
  800422:	e8 53 09 00 00       	call   800d7a <sys_cputs>

	return b.cnt;
}
  800427:	8b 85 f4 fe ff ff    	mov    -0x10c(%ebp),%eax
  80042d:	c9                   	leave  
  80042e:	c3                   	ret    

0080042f <cprintf>:

int
cprintf(const char *fmt, ...)
{
  80042f:	f3 0f 1e fb          	endbr32 
  800433:	55                   	push   %ebp
  800434:	89 e5                	mov    %esp,%ebp
  800436:	83 ec 10             	sub    $0x10,%esp
	va_list ap;
	int cnt;

	va_start(ap, fmt);
  800439:	8d 45 0c             	lea    0xc(%ebp),%eax
	cnt = vcprintf(fmt, ap);
  80043c:	50                   	push   %eax
  80043d:	ff 75 08             	pushl  0x8(%ebp)
  800440:	e8 95 ff ff ff       	call   8003da <vcprintf>
	va_end(ap);

	return cnt;
}
  800445:	c9                   	leave  
  800446:	c3                   	ret    

00800447 <printnum>:
 * using specified putch function and associated pointer putdat.
 */
static void
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
  800447:	55                   	push   %ebp
  800448:	89 e5                	mov    %esp,%ebp
  80044a:	57                   	push   %edi
  80044b:	56                   	push   %esi
  80044c:	53                   	push   %ebx
  80044d:	83 ec 1c             	sub    $0x1c,%esp
  800450:	89 c7                	mov    %eax,%edi
  800452:	89 d6                	mov    %edx,%esi
  800454:	8b 45 08             	mov    0x8(%ebp),%eax
  800457:	8b 55 0c             	mov    0xc(%ebp),%edx
  80045a:	89 d1                	mov    %edx,%ecx
  80045c:	89 c2                	mov    %eax,%edx
  80045e:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800461:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  800464:	8b 45 10             	mov    0x10(%ebp),%eax
  800467:	8b 5d 14             	mov    0x14(%ebp),%ebx
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
  80046a:	89 45 e0             	mov    %eax,-0x20(%ebp)
  80046d:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  800474:	39 c2                	cmp    %eax,%edx
  800476:	1b 4d e4             	sbb    -0x1c(%ebp),%ecx
  800479:	72 3e                	jb     8004b9 <printnum+0x72>
		printnum(putch, putdat, num / base, base, width - 1, padc);
  80047b:	83 ec 0c             	sub    $0xc,%esp
  80047e:	ff 75 18             	pushl  0x18(%ebp)
  800481:	83 eb 01             	sub    $0x1,%ebx
  800484:	53                   	push   %ebx
  800485:	50                   	push   %eax
  800486:	83 ec 08             	sub    $0x8,%esp
  800489:	ff 75 e4             	pushl  -0x1c(%ebp)
  80048c:	ff 75 e0             	pushl  -0x20(%ebp)
  80048f:	ff 75 dc             	pushl  -0x24(%ebp)
  800492:	ff 75 d8             	pushl  -0x28(%ebp)
  800495:	e8 96 1e 00 00       	call   802330 <__udivdi3>
  80049a:	83 c4 18             	add    $0x18,%esp
  80049d:	52                   	push   %edx
  80049e:	50                   	push   %eax
  80049f:	89 f2                	mov    %esi,%edx
  8004a1:	89 f8                	mov    %edi,%eax
  8004a3:	e8 9f ff ff ff       	call   800447 <printnum>
  8004a8:	83 c4 20             	add    $0x20,%esp
  8004ab:	eb 13                	jmp    8004c0 <printnum+0x79>
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
			putch(padc, putdat);
  8004ad:	83 ec 08             	sub    $0x8,%esp
  8004b0:	56                   	push   %esi
  8004b1:	ff 75 18             	pushl  0x18(%ebp)
  8004b4:	ff d7                	call   *%edi
  8004b6:	83 c4 10             	add    $0x10,%esp
		while (--width > 0)
  8004b9:	83 eb 01             	sub    $0x1,%ebx
  8004bc:	85 db                	test   %ebx,%ebx
  8004be:	7f ed                	jg     8004ad <printnum+0x66>
	}

	// then print this (the least significant) digit
	putch("0123456789abcdef"[num % base], putdat);
  8004c0:	83 ec 08             	sub    $0x8,%esp
  8004c3:	56                   	push   %esi
  8004c4:	83 ec 04             	sub    $0x4,%esp
  8004c7:	ff 75 e4             	pushl  -0x1c(%ebp)
  8004ca:	ff 75 e0             	pushl  -0x20(%ebp)
  8004cd:	ff 75 dc             	pushl  -0x24(%ebp)
  8004d0:	ff 75 d8             	pushl  -0x28(%ebp)
  8004d3:	e8 68 1f 00 00       	call   802440 <__umoddi3>
  8004d8:	83 c4 14             	add    $0x14,%esp
  8004db:	0f be 80 1b 27 80 00 	movsbl 0x80271b(%eax),%eax
  8004e2:	50                   	push   %eax
  8004e3:	ff d7                	call   *%edi
}
  8004e5:	83 c4 10             	add    $0x10,%esp
  8004e8:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8004eb:	5b                   	pop    %ebx
  8004ec:	5e                   	pop    %esi
  8004ed:	5f                   	pop    %edi
  8004ee:	5d                   	pop    %ebp
  8004ef:	c3                   	ret    

008004f0 <sprintputch>:
	int cnt;
};

static void
sprintputch(int ch, struct sprintbuf *b)
{
  8004f0:	f3 0f 1e fb          	endbr32 
  8004f4:	55                   	push   %ebp
  8004f5:	89 e5                	mov    %esp,%ebp
  8004f7:	8b 45 0c             	mov    0xc(%ebp),%eax
	b->cnt++;
  8004fa:	83 40 08 01          	addl   $0x1,0x8(%eax)
	if (b->buf < b->ebuf)
  8004fe:	8b 10                	mov    (%eax),%edx
  800500:	3b 50 04             	cmp    0x4(%eax),%edx
  800503:	73 0a                	jae    80050f <sprintputch+0x1f>
		*b->buf++ = ch;
  800505:	8d 4a 01             	lea    0x1(%edx),%ecx
  800508:	89 08                	mov    %ecx,(%eax)
  80050a:	8b 45 08             	mov    0x8(%ebp),%eax
  80050d:	88 02                	mov    %al,(%edx)
}
  80050f:	5d                   	pop    %ebp
  800510:	c3                   	ret    

00800511 <printfmt>:
{
  800511:	f3 0f 1e fb          	endbr32 
  800515:	55                   	push   %ebp
  800516:	89 e5                	mov    %esp,%ebp
  800518:	83 ec 08             	sub    $0x8,%esp
	va_start(ap, fmt);
  80051b:	8d 45 14             	lea    0x14(%ebp),%eax
	vprintfmt(putch, putdat, fmt, ap);
  80051e:	50                   	push   %eax
  80051f:	ff 75 10             	pushl  0x10(%ebp)
  800522:	ff 75 0c             	pushl  0xc(%ebp)
  800525:	ff 75 08             	pushl  0x8(%ebp)
  800528:	e8 05 00 00 00       	call   800532 <vprintfmt>
}
  80052d:	83 c4 10             	add    $0x10,%esp
  800530:	c9                   	leave  
  800531:	c3                   	ret    

00800532 <vprintfmt>:
{
  800532:	f3 0f 1e fb          	endbr32 
  800536:	55                   	push   %ebp
  800537:	89 e5                	mov    %esp,%ebp
  800539:	57                   	push   %edi
  80053a:	56                   	push   %esi
  80053b:	53                   	push   %ebx
  80053c:	83 ec 3c             	sub    $0x3c,%esp
  80053f:	8b 75 08             	mov    0x8(%ebp),%esi
  800542:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800545:	8b 7d 10             	mov    0x10(%ebp),%edi
  800548:	e9 5d 03 00 00       	jmp    8008aa <vprintfmt+0x378>
		padc = ' ';
  80054d:	c6 45 d3 20          	movb   $0x20,-0x2d(%ebp)
		altflag = 0;
  800551:	c7 45 e0 00 00 00 00 	movl   $0x0,-0x20(%ebp)
		precision = -1;
  800558:	c7 45 d8 ff ff ff ff 	movl   $0xffffffff,-0x28(%ebp)
		width = -1;
  80055f:	c7 45 d4 ff ff ff ff 	movl   $0xffffffff,-0x2c(%ebp)
		lflag = 0;
  800566:	b9 00 00 00 00       	mov    $0x0,%ecx
		switch (ch = *(unsigned char *) fmt++) {
  80056b:	8d 47 01             	lea    0x1(%edi),%eax
  80056e:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  800571:	0f b6 17             	movzbl (%edi),%edx
  800574:	8d 42 dd             	lea    -0x23(%edx),%eax
  800577:	3c 55                	cmp    $0x55,%al
  800579:	0f 87 ae 03 00 00    	ja     80092d <vprintfmt+0x3fb>
  80057f:	0f b6 c0             	movzbl %al,%eax
  800582:	3e ff 24 85 60 28 80 	notrack jmp *0x802860(,%eax,4)
  800589:	00 
  80058a:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			padc = '-';
  80058d:	c6 45 d3 2d          	movb   $0x2d,-0x2d(%ebp)
  800591:	eb d8                	jmp    80056b <vprintfmt+0x39>
		switch (ch = *(unsigned char *) fmt++) {
  800593:	8b 7d e4             	mov    -0x1c(%ebp),%edi
  800596:	c6 45 d3 30          	movb   $0x30,-0x2d(%ebp)
  80059a:	eb cf                	jmp    80056b <vprintfmt+0x39>
  80059c:	0f b6 d2             	movzbl %dl,%edx
  80059f:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			for (precision = 0; ; ++fmt) {
  8005a2:	b8 00 00 00 00       	mov    $0x0,%eax
  8005a7:	89 4d e4             	mov    %ecx,-0x1c(%ebp)
				precision = precision * 10 + ch - '0';
  8005aa:	8d 04 80             	lea    (%eax,%eax,4),%eax
  8005ad:	8d 44 42 d0          	lea    -0x30(%edx,%eax,2),%eax
				ch = *fmt;
  8005b1:	0f be 17             	movsbl (%edi),%edx
				if (ch < '0' || ch > '9')
  8005b4:	8d 4a d0             	lea    -0x30(%edx),%ecx
  8005b7:	83 f9 09             	cmp    $0x9,%ecx
  8005ba:	77 55                	ja     800611 <vprintfmt+0xdf>
			for (precision = 0; ; ++fmt) {
  8005bc:	83 c7 01             	add    $0x1,%edi
				precision = precision * 10 + ch - '0';
  8005bf:	eb e9                	jmp    8005aa <vprintfmt+0x78>
			precision = va_arg(ap, int);
  8005c1:	8b 45 14             	mov    0x14(%ebp),%eax
  8005c4:	8b 00                	mov    (%eax),%eax
  8005c6:	89 45 d8             	mov    %eax,-0x28(%ebp)
  8005c9:	8b 45 14             	mov    0x14(%ebp),%eax
  8005cc:	8d 40 04             	lea    0x4(%eax),%eax
  8005cf:	89 45 14             	mov    %eax,0x14(%ebp)
		switch (ch = *(unsigned char *) fmt++) {
  8005d2:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			if (width < 0)
  8005d5:	83 7d d4 00          	cmpl   $0x0,-0x2c(%ebp)
  8005d9:	79 90                	jns    80056b <vprintfmt+0x39>
				width = precision, precision = -1;
  8005db:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8005de:	89 45 d4             	mov    %eax,-0x2c(%ebp)
  8005e1:	c7 45 d8 ff ff ff ff 	movl   $0xffffffff,-0x28(%ebp)
  8005e8:	eb 81                	jmp    80056b <vprintfmt+0x39>
  8005ea:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  8005ed:	85 c0                	test   %eax,%eax
  8005ef:	ba 00 00 00 00       	mov    $0x0,%edx
  8005f4:	0f 49 d0             	cmovns %eax,%edx
  8005f7:	89 55 d4             	mov    %edx,-0x2c(%ebp)
		switch (ch = *(unsigned char *) fmt++) {
  8005fa:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			goto reswitch;
  8005fd:	e9 69 ff ff ff       	jmp    80056b <vprintfmt+0x39>
		switch (ch = *(unsigned char *) fmt++) {
  800602:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			altflag = 1;
  800605:	c7 45 e0 01 00 00 00 	movl   $0x1,-0x20(%ebp)
			goto reswitch;
  80060c:	e9 5a ff ff ff       	jmp    80056b <vprintfmt+0x39>
  800611:	8b 4d e4             	mov    -0x1c(%ebp),%ecx
  800614:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800617:	eb bc                	jmp    8005d5 <vprintfmt+0xa3>
			lflag++;
  800619:	83 c1 01             	add    $0x1,%ecx
		switch (ch = *(unsigned char *) fmt++) {
  80061c:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			goto reswitch;
  80061f:	e9 47 ff ff ff       	jmp    80056b <vprintfmt+0x39>
			putch(va_arg(ap, int), putdat);
  800624:	8b 45 14             	mov    0x14(%ebp),%eax
  800627:	8d 78 04             	lea    0x4(%eax),%edi
  80062a:	83 ec 08             	sub    $0x8,%esp
  80062d:	53                   	push   %ebx
  80062e:	ff 30                	pushl  (%eax)
  800630:	ff d6                	call   *%esi
			break;
  800632:	83 c4 10             	add    $0x10,%esp
			putch(va_arg(ap, int), putdat);
  800635:	89 7d 14             	mov    %edi,0x14(%ebp)
			break;
  800638:	e9 6a 02 00 00       	jmp    8008a7 <vprintfmt+0x375>
			err = va_arg(ap, int);
  80063d:	8b 45 14             	mov    0x14(%ebp),%eax
  800640:	8d 78 04             	lea    0x4(%eax),%edi
  800643:	8b 00                	mov    (%eax),%eax
  800645:	99                   	cltd   
  800646:	31 d0                	xor    %edx,%eax
  800648:	29 d0                	sub    %edx,%eax
			if (err >= MAXERROR || (p = error_string[err]) == NULL)
  80064a:	83 f8 0f             	cmp    $0xf,%eax
  80064d:	7f 23                	jg     800672 <vprintfmt+0x140>
  80064f:	8b 14 85 c0 29 80 00 	mov    0x8029c0(,%eax,4),%edx
  800656:	85 d2                	test   %edx,%edx
  800658:	74 18                	je     800672 <vprintfmt+0x140>
				printfmt(putch, putdat, "%s", p);
  80065a:	52                   	push   %edx
  80065b:	68 41 2c 80 00       	push   $0x802c41
  800660:	53                   	push   %ebx
  800661:	56                   	push   %esi
  800662:	e8 aa fe ff ff       	call   800511 <printfmt>
  800667:	83 c4 10             	add    $0x10,%esp
			err = va_arg(ap, int);
  80066a:	89 7d 14             	mov    %edi,0x14(%ebp)
  80066d:	e9 35 02 00 00       	jmp    8008a7 <vprintfmt+0x375>
				printfmt(putch, putdat, "error %d", err);
  800672:	50                   	push   %eax
  800673:	68 33 27 80 00       	push   $0x802733
  800678:	53                   	push   %ebx
  800679:	56                   	push   %esi
  80067a:	e8 92 fe ff ff       	call   800511 <printfmt>
  80067f:	83 c4 10             	add    $0x10,%esp
			err = va_arg(ap, int);
  800682:	89 7d 14             	mov    %edi,0x14(%ebp)
				printfmt(putch, putdat, "error %d", err);
  800685:	e9 1d 02 00 00       	jmp    8008a7 <vprintfmt+0x375>
			if ((p = va_arg(ap, char *)) == NULL)
  80068a:	8b 45 14             	mov    0x14(%ebp),%eax
  80068d:	83 c0 04             	add    $0x4,%eax
  800690:	89 45 c8             	mov    %eax,-0x38(%ebp)
  800693:	8b 45 14             	mov    0x14(%ebp),%eax
  800696:	8b 10                	mov    (%eax),%edx
				p = "(null)";
  800698:	85 d2                	test   %edx,%edx
  80069a:	b8 2c 27 80 00       	mov    $0x80272c,%eax
  80069f:	0f 45 c2             	cmovne %edx,%eax
  8006a2:	89 45 cc             	mov    %eax,-0x34(%ebp)
			if (width > 0 && padc != '-')
  8006a5:	83 7d d4 00          	cmpl   $0x0,-0x2c(%ebp)
  8006a9:	7e 06                	jle    8006b1 <vprintfmt+0x17f>
  8006ab:	80 7d d3 2d          	cmpb   $0x2d,-0x2d(%ebp)
  8006af:	75 0d                	jne    8006be <vprintfmt+0x18c>
				for (width -= strnlen(p, precision); width > 0; width--)
  8006b1:	8b 45 cc             	mov    -0x34(%ebp),%eax
  8006b4:	89 c7                	mov    %eax,%edi
  8006b6:	03 45 d4             	add    -0x2c(%ebp),%eax
  8006b9:	89 45 d4             	mov    %eax,-0x2c(%ebp)
  8006bc:	eb 55                	jmp    800713 <vprintfmt+0x1e1>
  8006be:	83 ec 08             	sub    $0x8,%esp
  8006c1:	ff 75 d8             	pushl  -0x28(%ebp)
  8006c4:	ff 75 cc             	pushl  -0x34(%ebp)
  8006c7:	e8 15 03 00 00       	call   8009e1 <strnlen>
  8006cc:	8b 55 d4             	mov    -0x2c(%ebp),%edx
  8006cf:	29 c2                	sub    %eax,%edx
  8006d1:	89 55 c4             	mov    %edx,-0x3c(%ebp)
  8006d4:	83 c4 10             	add    $0x10,%esp
  8006d7:	89 d7                	mov    %edx,%edi
					putch(padc, putdat);
  8006d9:	0f be 45 d3          	movsbl -0x2d(%ebp),%eax
  8006dd:	89 45 d4             	mov    %eax,-0x2c(%ebp)
				for (width -= strnlen(p, precision); width > 0; width--)
  8006e0:	85 ff                	test   %edi,%edi
  8006e2:	7e 11                	jle    8006f5 <vprintfmt+0x1c3>
					putch(padc, putdat);
  8006e4:	83 ec 08             	sub    $0x8,%esp
  8006e7:	53                   	push   %ebx
  8006e8:	ff 75 d4             	pushl  -0x2c(%ebp)
  8006eb:	ff d6                	call   *%esi
				for (width -= strnlen(p, precision); width > 0; width--)
  8006ed:	83 ef 01             	sub    $0x1,%edi
  8006f0:	83 c4 10             	add    $0x10,%esp
  8006f3:	eb eb                	jmp    8006e0 <vprintfmt+0x1ae>
  8006f5:	8b 55 c4             	mov    -0x3c(%ebp),%edx
  8006f8:	85 d2                	test   %edx,%edx
  8006fa:	b8 00 00 00 00       	mov    $0x0,%eax
  8006ff:	0f 49 c2             	cmovns %edx,%eax
  800702:	29 c2                	sub    %eax,%edx
  800704:	89 55 d4             	mov    %edx,-0x2c(%ebp)
  800707:	eb a8                	jmp    8006b1 <vprintfmt+0x17f>
					putch(ch, putdat);
  800709:	83 ec 08             	sub    $0x8,%esp
  80070c:	53                   	push   %ebx
  80070d:	52                   	push   %edx
  80070e:	ff d6                	call   *%esi
  800710:	83 c4 10             	add    $0x10,%esp
  800713:	8b 4d d4             	mov    -0x2c(%ebp),%ecx
  800716:	29 f9                	sub    %edi,%ecx
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800718:	83 c7 01             	add    $0x1,%edi
  80071b:	0f b6 47 ff          	movzbl -0x1(%edi),%eax
  80071f:	0f be d0             	movsbl %al,%edx
  800722:	85 d2                	test   %edx,%edx
  800724:	74 4b                	je     800771 <vprintfmt+0x23f>
  800726:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  80072a:	78 06                	js     800732 <vprintfmt+0x200>
  80072c:	83 6d d8 01          	subl   $0x1,-0x28(%ebp)
  800730:	78 1e                	js     800750 <vprintfmt+0x21e>
				if (altflag && (ch < ' ' || ch > '~'))
  800732:	83 7d e0 00          	cmpl   $0x0,-0x20(%ebp)
  800736:	74 d1                	je     800709 <vprintfmt+0x1d7>
  800738:	0f be c0             	movsbl %al,%eax
  80073b:	83 e8 20             	sub    $0x20,%eax
  80073e:	83 f8 5e             	cmp    $0x5e,%eax
  800741:	76 c6                	jbe    800709 <vprintfmt+0x1d7>
					putch('?', putdat);
  800743:	83 ec 08             	sub    $0x8,%esp
  800746:	53                   	push   %ebx
  800747:	6a 3f                	push   $0x3f
  800749:	ff d6                	call   *%esi
  80074b:	83 c4 10             	add    $0x10,%esp
  80074e:	eb c3                	jmp    800713 <vprintfmt+0x1e1>
  800750:	89 cf                	mov    %ecx,%edi
  800752:	eb 0e                	jmp    800762 <vprintfmt+0x230>
				putch(' ', putdat);
  800754:	83 ec 08             	sub    $0x8,%esp
  800757:	53                   	push   %ebx
  800758:	6a 20                	push   $0x20
  80075a:	ff d6                	call   *%esi
			for (; width > 0; width--)
  80075c:	83 ef 01             	sub    $0x1,%edi
  80075f:	83 c4 10             	add    $0x10,%esp
  800762:	85 ff                	test   %edi,%edi
  800764:	7f ee                	jg     800754 <vprintfmt+0x222>
			if ((p = va_arg(ap, char *)) == NULL)
  800766:	8b 45 c8             	mov    -0x38(%ebp),%eax
  800769:	89 45 14             	mov    %eax,0x14(%ebp)
  80076c:	e9 36 01 00 00       	jmp    8008a7 <vprintfmt+0x375>
  800771:	89 cf                	mov    %ecx,%edi
  800773:	eb ed                	jmp    800762 <vprintfmt+0x230>
	if (lflag >= 2)
  800775:	83 f9 01             	cmp    $0x1,%ecx
  800778:	7f 1f                	jg     800799 <vprintfmt+0x267>
	else if (lflag)
  80077a:	85 c9                	test   %ecx,%ecx
  80077c:	74 67                	je     8007e5 <vprintfmt+0x2b3>
		return va_arg(*ap, long);
  80077e:	8b 45 14             	mov    0x14(%ebp),%eax
  800781:	8b 00                	mov    (%eax),%eax
  800783:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800786:	89 c1                	mov    %eax,%ecx
  800788:	c1 f9 1f             	sar    $0x1f,%ecx
  80078b:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  80078e:	8b 45 14             	mov    0x14(%ebp),%eax
  800791:	8d 40 04             	lea    0x4(%eax),%eax
  800794:	89 45 14             	mov    %eax,0x14(%ebp)
  800797:	eb 17                	jmp    8007b0 <vprintfmt+0x27e>
		return va_arg(*ap, long long);
  800799:	8b 45 14             	mov    0x14(%ebp),%eax
  80079c:	8b 50 04             	mov    0x4(%eax),%edx
  80079f:	8b 00                	mov    (%eax),%eax
  8007a1:	89 45 d8             	mov    %eax,-0x28(%ebp)
  8007a4:	89 55 dc             	mov    %edx,-0x24(%ebp)
  8007a7:	8b 45 14             	mov    0x14(%ebp),%eax
  8007aa:	8d 40 08             	lea    0x8(%eax),%eax
  8007ad:	89 45 14             	mov    %eax,0x14(%ebp)
			if ((long long) num < 0) {
  8007b0:	8b 55 d8             	mov    -0x28(%ebp),%edx
  8007b3:	8b 4d dc             	mov    -0x24(%ebp),%ecx
			base = 10;
  8007b6:	b8 0a 00 00 00       	mov    $0xa,%eax
			if ((long long) num < 0) {
  8007bb:	85 c9                	test   %ecx,%ecx
  8007bd:	0f 89 ca 00 00 00    	jns    80088d <vprintfmt+0x35b>
				putch('-', putdat);
  8007c3:	83 ec 08             	sub    $0x8,%esp
  8007c6:	53                   	push   %ebx
  8007c7:	6a 2d                	push   $0x2d
  8007c9:	ff d6                	call   *%esi
				num = -(long long) num;
  8007cb:	8b 55 d8             	mov    -0x28(%ebp),%edx
  8007ce:	8b 4d dc             	mov    -0x24(%ebp),%ecx
  8007d1:	f7 da                	neg    %edx
  8007d3:	83 d1 00             	adc    $0x0,%ecx
  8007d6:	f7 d9                	neg    %ecx
  8007d8:	83 c4 10             	add    $0x10,%esp
			base = 10;
  8007db:	b8 0a 00 00 00       	mov    $0xa,%eax
  8007e0:	e9 a8 00 00 00       	jmp    80088d <vprintfmt+0x35b>
		return va_arg(*ap, int);
  8007e5:	8b 45 14             	mov    0x14(%ebp),%eax
  8007e8:	8b 00                	mov    (%eax),%eax
  8007ea:	89 45 d8             	mov    %eax,-0x28(%ebp)
  8007ed:	99                   	cltd   
  8007ee:	89 55 dc             	mov    %edx,-0x24(%ebp)
  8007f1:	8b 45 14             	mov    0x14(%ebp),%eax
  8007f4:	8d 40 04             	lea    0x4(%eax),%eax
  8007f7:	89 45 14             	mov    %eax,0x14(%ebp)
  8007fa:	eb b4                	jmp    8007b0 <vprintfmt+0x27e>
	if (lflag >= 2)
  8007fc:	83 f9 01             	cmp    $0x1,%ecx
  8007ff:	7f 1b                	jg     80081c <vprintfmt+0x2ea>
	else if (lflag)
  800801:	85 c9                	test   %ecx,%ecx
  800803:	74 2c                	je     800831 <vprintfmt+0x2ff>
		return va_arg(*ap, unsigned long);
  800805:	8b 45 14             	mov    0x14(%ebp),%eax
  800808:	8b 10                	mov    (%eax),%edx
  80080a:	b9 00 00 00 00       	mov    $0x0,%ecx
  80080f:	8d 40 04             	lea    0x4(%eax),%eax
  800812:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 10;
  800815:	b8 0a 00 00 00       	mov    $0xa,%eax
		return va_arg(*ap, unsigned long);
  80081a:	eb 71                	jmp    80088d <vprintfmt+0x35b>
		return va_arg(*ap, unsigned long long);
  80081c:	8b 45 14             	mov    0x14(%ebp),%eax
  80081f:	8b 10                	mov    (%eax),%edx
  800821:	8b 48 04             	mov    0x4(%eax),%ecx
  800824:	8d 40 08             	lea    0x8(%eax),%eax
  800827:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 10;
  80082a:	b8 0a 00 00 00       	mov    $0xa,%eax
		return va_arg(*ap, unsigned long long);
  80082f:	eb 5c                	jmp    80088d <vprintfmt+0x35b>
		return va_arg(*ap, unsigned int);
  800831:	8b 45 14             	mov    0x14(%ebp),%eax
  800834:	8b 10                	mov    (%eax),%edx
  800836:	b9 00 00 00 00       	mov    $0x0,%ecx
  80083b:	8d 40 04             	lea    0x4(%eax),%eax
  80083e:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 10;
  800841:	b8 0a 00 00 00       	mov    $0xa,%eax
		return va_arg(*ap, unsigned int);
  800846:	eb 45                	jmp    80088d <vprintfmt+0x35b>
			putch('X', putdat);
  800848:	83 ec 08             	sub    $0x8,%esp
  80084b:	53                   	push   %ebx
  80084c:	6a 58                	push   $0x58
  80084e:	ff d6                	call   *%esi
			putch('X', putdat);
  800850:	83 c4 08             	add    $0x8,%esp
  800853:	53                   	push   %ebx
  800854:	6a 58                	push   $0x58
  800856:	ff d6                	call   *%esi
			putch('X', putdat);
  800858:	83 c4 08             	add    $0x8,%esp
  80085b:	53                   	push   %ebx
  80085c:	6a 58                	push   $0x58
  80085e:	ff d6                	call   *%esi
			break;
  800860:	83 c4 10             	add    $0x10,%esp
  800863:	eb 42                	jmp    8008a7 <vprintfmt+0x375>
			putch('0', putdat);
  800865:	83 ec 08             	sub    $0x8,%esp
  800868:	53                   	push   %ebx
  800869:	6a 30                	push   $0x30
  80086b:	ff d6                	call   *%esi
			putch('x', putdat);
  80086d:	83 c4 08             	add    $0x8,%esp
  800870:	53                   	push   %ebx
  800871:	6a 78                	push   $0x78
  800873:	ff d6                	call   *%esi
			num = (unsigned long long)
  800875:	8b 45 14             	mov    0x14(%ebp),%eax
  800878:	8b 10                	mov    (%eax),%edx
  80087a:	b9 00 00 00 00       	mov    $0x0,%ecx
			goto number;
  80087f:	83 c4 10             	add    $0x10,%esp
				(uintptr_t) va_arg(ap, void *);
  800882:	8d 40 04             	lea    0x4(%eax),%eax
  800885:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 16;
  800888:	b8 10 00 00 00       	mov    $0x10,%eax
			printnum(putch, putdat, num, base, width, padc);
  80088d:	83 ec 0c             	sub    $0xc,%esp
  800890:	0f be 7d d3          	movsbl -0x2d(%ebp),%edi
  800894:	57                   	push   %edi
  800895:	ff 75 d4             	pushl  -0x2c(%ebp)
  800898:	50                   	push   %eax
  800899:	51                   	push   %ecx
  80089a:	52                   	push   %edx
  80089b:	89 da                	mov    %ebx,%edx
  80089d:	89 f0                	mov    %esi,%eax
  80089f:	e8 a3 fb ff ff       	call   800447 <printnum>
			break;
  8008a4:	83 c4 20             	add    $0x20,%esp
			if ((p = va_arg(ap, char *)) == NULL)
  8008a7:	8b 7d e4             	mov    -0x1c(%ebp),%edi
		while ((ch = *(unsigned char *) fmt++) != '%') {
  8008aa:	83 c7 01             	add    $0x1,%edi
  8008ad:	0f b6 47 ff          	movzbl -0x1(%edi),%eax
  8008b1:	83 f8 25             	cmp    $0x25,%eax
  8008b4:	0f 84 93 fc ff ff    	je     80054d <vprintfmt+0x1b>
			if (ch == '\0')
  8008ba:	85 c0                	test   %eax,%eax
  8008bc:	0f 84 8b 00 00 00    	je     80094d <vprintfmt+0x41b>
			putch(ch, putdat);
  8008c2:	83 ec 08             	sub    $0x8,%esp
  8008c5:	53                   	push   %ebx
  8008c6:	50                   	push   %eax
  8008c7:	ff d6                	call   *%esi
  8008c9:	83 c4 10             	add    $0x10,%esp
  8008cc:	eb dc                	jmp    8008aa <vprintfmt+0x378>
	if (lflag >= 2)
  8008ce:	83 f9 01             	cmp    $0x1,%ecx
  8008d1:	7f 1b                	jg     8008ee <vprintfmt+0x3bc>
	else if (lflag)
  8008d3:	85 c9                	test   %ecx,%ecx
  8008d5:	74 2c                	je     800903 <vprintfmt+0x3d1>
		return va_arg(*ap, unsigned long);
  8008d7:	8b 45 14             	mov    0x14(%ebp),%eax
  8008da:	8b 10                	mov    (%eax),%edx
  8008dc:	b9 00 00 00 00       	mov    $0x0,%ecx
  8008e1:	8d 40 04             	lea    0x4(%eax),%eax
  8008e4:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 16;
  8008e7:	b8 10 00 00 00       	mov    $0x10,%eax
		return va_arg(*ap, unsigned long);
  8008ec:	eb 9f                	jmp    80088d <vprintfmt+0x35b>
		return va_arg(*ap, unsigned long long);
  8008ee:	8b 45 14             	mov    0x14(%ebp),%eax
  8008f1:	8b 10                	mov    (%eax),%edx
  8008f3:	8b 48 04             	mov    0x4(%eax),%ecx
  8008f6:	8d 40 08             	lea    0x8(%eax),%eax
  8008f9:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 16;
  8008fc:	b8 10 00 00 00       	mov    $0x10,%eax
		return va_arg(*ap, unsigned long long);
  800901:	eb 8a                	jmp    80088d <vprintfmt+0x35b>
		return va_arg(*ap, unsigned int);
  800903:	8b 45 14             	mov    0x14(%ebp),%eax
  800906:	8b 10                	mov    (%eax),%edx
  800908:	b9 00 00 00 00       	mov    $0x0,%ecx
  80090d:	8d 40 04             	lea    0x4(%eax),%eax
  800910:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 16;
  800913:	b8 10 00 00 00       	mov    $0x10,%eax
		return va_arg(*ap, unsigned int);
  800918:	e9 70 ff ff ff       	jmp    80088d <vprintfmt+0x35b>
			putch(ch, putdat);
  80091d:	83 ec 08             	sub    $0x8,%esp
  800920:	53                   	push   %ebx
  800921:	6a 25                	push   $0x25
  800923:	ff d6                	call   *%esi
			break;
  800925:	83 c4 10             	add    $0x10,%esp
  800928:	e9 7a ff ff ff       	jmp    8008a7 <vprintfmt+0x375>
			putch('%', putdat);
  80092d:	83 ec 08             	sub    $0x8,%esp
  800930:	53                   	push   %ebx
  800931:	6a 25                	push   $0x25
  800933:	ff d6                	call   *%esi
			for (fmt--; fmt[-1] != '%'; fmt--)
  800935:	83 c4 10             	add    $0x10,%esp
  800938:	89 f8                	mov    %edi,%eax
  80093a:	80 78 ff 25          	cmpb   $0x25,-0x1(%eax)
  80093e:	74 05                	je     800945 <vprintfmt+0x413>
  800940:	83 e8 01             	sub    $0x1,%eax
  800943:	eb f5                	jmp    80093a <vprintfmt+0x408>
  800945:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  800948:	e9 5a ff ff ff       	jmp    8008a7 <vprintfmt+0x375>
}
  80094d:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800950:	5b                   	pop    %ebx
  800951:	5e                   	pop    %esi
  800952:	5f                   	pop    %edi
  800953:	5d                   	pop    %ebp
  800954:	c3                   	ret    

00800955 <vsnprintf>:

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
  800955:	f3 0f 1e fb          	endbr32 
  800959:	55                   	push   %ebp
  80095a:	89 e5                	mov    %esp,%ebp
  80095c:	83 ec 18             	sub    $0x18,%esp
  80095f:	8b 45 08             	mov    0x8(%ebp),%eax
  800962:	8b 55 0c             	mov    0xc(%ebp),%edx
	struct sprintbuf b = {buf, buf+n-1, 0};
  800965:	89 45 ec             	mov    %eax,-0x14(%ebp)
  800968:	8d 4c 10 ff          	lea    -0x1(%eax,%edx,1),%ecx
  80096c:	89 4d f0             	mov    %ecx,-0x10(%ebp)
  80096f:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)

	if (buf == NULL || n < 1)
  800976:	85 c0                	test   %eax,%eax
  800978:	74 26                	je     8009a0 <vsnprintf+0x4b>
  80097a:	85 d2                	test   %edx,%edx
  80097c:	7e 22                	jle    8009a0 <vsnprintf+0x4b>
		return -E_INVAL;

	// print the string to the buffer
	vprintfmt((void*)sprintputch, &b, fmt, ap);
  80097e:	ff 75 14             	pushl  0x14(%ebp)
  800981:	ff 75 10             	pushl  0x10(%ebp)
  800984:	8d 45 ec             	lea    -0x14(%ebp),%eax
  800987:	50                   	push   %eax
  800988:	68 f0 04 80 00       	push   $0x8004f0
  80098d:	e8 a0 fb ff ff       	call   800532 <vprintfmt>

	// null terminate the buffer
	*b.buf = '\0';
  800992:	8b 45 ec             	mov    -0x14(%ebp),%eax
  800995:	c6 00 00             	movb   $0x0,(%eax)

	return b.cnt;
  800998:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80099b:	83 c4 10             	add    $0x10,%esp
}
  80099e:	c9                   	leave  
  80099f:	c3                   	ret    
		return -E_INVAL;
  8009a0:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  8009a5:	eb f7                	jmp    80099e <vsnprintf+0x49>

008009a7 <snprintf>:

int
snprintf(char *buf, int n, const char *fmt, ...)
{
  8009a7:	f3 0f 1e fb          	endbr32 
  8009ab:	55                   	push   %ebp
  8009ac:	89 e5                	mov    %esp,%ebp
  8009ae:	83 ec 08             	sub    $0x8,%esp
	va_list ap;
	int rc;

	va_start(ap, fmt);
  8009b1:	8d 45 14             	lea    0x14(%ebp),%eax
	rc = vsnprintf(buf, n, fmt, ap);
  8009b4:	50                   	push   %eax
  8009b5:	ff 75 10             	pushl  0x10(%ebp)
  8009b8:	ff 75 0c             	pushl  0xc(%ebp)
  8009bb:	ff 75 08             	pushl  0x8(%ebp)
  8009be:	e8 92 ff ff ff       	call   800955 <vsnprintf>
	va_end(ap);

	return rc;
}
  8009c3:	c9                   	leave  
  8009c4:	c3                   	ret    

008009c5 <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1

int
strlen(const char *s)
{
  8009c5:	f3 0f 1e fb          	endbr32 
  8009c9:	55                   	push   %ebp
  8009ca:	89 e5                	mov    %esp,%ebp
  8009cc:	8b 55 08             	mov    0x8(%ebp),%edx
	int n;

	for (n = 0; *s != '\0'; s++)
  8009cf:	b8 00 00 00 00       	mov    $0x0,%eax
  8009d4:	80 3c 02 00          	cmpb   $0x0,(%edx,%eax,1)
  8009d8:	74 05                	je     8009df <strlen+0x1a>
		n++;
  8009da:	83 c0 01             	add    $0x1,%eax
  8009dd:	eb f5                	jmp    8009d4 <strlen+0xf>
	return n;
}
  8009df:	5d                   	pop    %ebp
  8009e0:	c3                   	ret    

008009e1 <strnlen>:

int
strnlen(const char *s, size_t size)
{
  8009e1:	f3 0f 1e fb          	endbr32 
  8009e5:	55                   	push   %ebp
  8009e6:	89 e5                	mov    %esp,%ebp
  8009e8:	8b 4d 08             	mov    0x8(%ebp),%ecx
  8009eb:	8b 55 0c             	mov    0xc(%ebp),%edx
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  8009ee:	b8 00 00 00 00       	mov    $0x0,%eax
  8009f3:	39 d0                	cmp    %edx,%eax
  8009f5:	74 0d                	je     800a04 <strnlen+0x23>
  8009f7:	80 3c 01 00          	cmpb   $0x0,(%ecx,%eax,1)
  8009fb:	74 05                	je     800a02 <strnlen+0x21>
		n++;
  8009fd:	83 c0 01             	add    $0x1,%eax
  800a00:	eb f1                	jmp    8009f3 <strnlen+0x12>
  800a02:	89 c2                	mov    %eax,%edx
	return n;
}
  800a04:	89 d0                	mov    %edx,%eax
  800a06:	5d                   	pop    %ebp
  800a07:	c3                   	ret    

00800a08 <strcpy>:

char *
strcpy(char *dst, const char *src)
{
  800a08:	f3 0f 1e fb          	endbr32 
  800a0c:	55                   	push   %ebp
  800a0d:	89 e5                	mov    %esp,%ebp
  800a0f:	53                   	push   %ebx
  800a10:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800a13:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	char *ret;

	ret = dst;
	while ((*dst++ = *src++) != '\0')
  800a16:	b8 00 00 00 00       	mov    $0x0,%eax
  800a1b:	0f b6 14 03          	movzbl (%ebx,%eax,1),%edx
  800a1f:	88 14 01             	mov    %dl,(%ecx,%eax,1)
  800a22:	83 c0 01             	add    $0x1,%eax
  800a25:	84 d2                	test   %dl,%dl
  800a27:	75 f2                	jne    800a1b <strcpy+0x13>
		/* do nothing */;
	return ret;
}
  800a29:	89 c8                	mov    %ecx,%eax
  800a2b:	5b                   	pop    %ebx
  800a2c:	5d                   	pop    %ebp
  800a2d:	c3                   	ret    

00800a2e <strcat>:

char *
strcat(char *dst, const char *src)
{
  800a2e:	f3 0f 1e fb          	endbr32 
  800a32:	55                   	push   %ebp
  800a33:	89 e5                	mov    %esp,%ebp
  800a35:	53                   	push   %ebx
  800a36:	83 ec 10             	sub    $0x10,%esp
  800a39:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int len = strlen(dst);
  800a3c:	53                   	push   %ebx
  800a3d:	e8 83 ff ff ff       	call   8009c5 <strlen>
  800a42:	83 c4 08             	add    $0x8,%esp
	strcpy(dst + len, src);
  800a45:	ff 75 0c             	pushl  0xc(%ebp)
  800a48:	01 d8                	add    %ebx,%eax
  800a4a:	50                   	push   %eax
  800a4b:	e8 b8 ff ff ff       	call   800a08 <strcpy>
	return dst;
}
  800a50:	89 d8                	mov    %ebx,%eax
  800a52:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  800a55:	c9                   	leave  
  800a56:	c3                   	ret    

00800a57 <strncpy>:

char *
strncpy(char *dst, const char *src, size_t size) {
  800a57:	f3 0f 1e fb          	endbr32 
  800a5b:	55                   	push   %ebp
  800a5c:	89 e5                	mov    %esp,%ebp
  800a5e:	56                   	push   %esi
  800a5f:	53                   	push   %ebx
  800a60:	8b 75 08             	mov    0x8(%ebp),%esi
  800a63:	8b 55 0c             	mov    0xc(%ebp),%edx
  800a66:	89 f3                	mov    %esi,%ebx
  800a68:	03 5d 10             	add    0x10(%ebp),%ebx
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  800a6b:	89 f0                	mov    %esi,%eax
  800a6d:	39 d8                	cmp    %ebx,%eax
  800a6f:	74 11                	je     800a82 <strncpy+0x2b>
		*dst++ = *src;
  800a71:	83 c0 01             	add    $0x1,%eax
  800a74:	0f b6 0a             	movzbl (%edx),%ecx
  800a77:	88 48 ff             	mov    %cl,-0x1(%eax)
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
  800a7a:	80 f9 01             	cmp    $0x1,%cl
  800a7d:	83 da ff             	sbb    $0xffffffff,%edx
  800a80:	eb eb                	jmp    800a6d <strncpy+0x16>
	}
	return ret;
}
  800a82:	89 f0                	mov    %esi,%eax
  800a84:	5b                   	pop    %ebx
  800a85:	5e                   	pop    %esi
  800a86:	5d                   	pop    %ebp
  800a87:	c3                   	ret    

00800a88 <strlcpy>:

size_t
strlcpy(char *dst, const char *src, size_t size)
{
  800a88:	f3 0f 1e fb          	endbr32 
  800a8c:	55                   	push   %ebp
  800a8d:	89 e5                	mov    %esp,%ebp
  800a8f:	56                   	push   %esi
  800a90:	53                   	push   %ebx
  800a91:	8b 75 08             	mov    0x8(%ebp),%esi
  800a94:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800a97:	8b 55 10             	mov    0x10(%ebp),%edx
  800a9a:	89 f0                	mov    %esi,%eax
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
  800a9c:	85 d2                	test   %edx,%edx
  800a9e:	74 21                	je     800ac1 <strlcpy+0x39>
  800aa0:	8d 44 16 ff          	lea    -0x1(%esi,%edx,1),%eax
  800aa4:	89 f2                	mov    %esi,%edx
		while (--size > 0 && *src != '\0')
  800aa6:	39 c2                	cmp    %eax,%edx
  800aa8:	74 14                	je     800abe <strlcpy+0x36>
  800aaa:	0f b6 19             	movzbl (%ecx),%ebx
  800aad:	84 db                	test   %bl,%bl
  800aaf:	74 0b                	je     800abc <strlcpy+0x34>
			*dst++ = *src++;
  800ab1:	83 c1 01             	add    $0x1,%ecx
  800ab4:	83 c2 01             	add    $0x1,%edx
  800ab7:	88 5a ff             	mov    %bl,-0x1(%edx)
  800aba:	eb ea                	jmp    800aa6 <strlcpy+0x1e>
  800abc:	89 d0                	mov    %edx,%eax
		*dst = '\0';
  800abe:	c6 00 00             	movb   $0x0,(%eax)
	}
	return dst - dst_in;
  800ac1:	29 f0                	sub    %esi,%eax
}
  800ac3:	5b                   	pop    %ebx
  800ac4:	5e                   	pop    %esi
  800ac5:	5d                   	pop    %ebp
  800ac6:	c3                   	ret    

00800ac7 <strcmp>:

int
strcmp(const char *p, const char *q)
{
  800ac7:	f3 0f 1e fb          	endbr32 
  800acb:	55                   	push   %ebp
  800acc:	89 e5                	mov    %esp,%ebp
  800ace:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800ad1:	8b 55 0c             	mov    0xc(%ebp),%edx
	while (*p && *p == *q)
  800ad4:	0f b6 01             	movzbl (%ecx),%eax
  800ad7:	84 c0                	test   %al,%al
  800ad9:	74 0c                	je     800ae7 <strcmp+0x20>
  800adb:	3a 02                	cmp    (%edx),%al
  800add:	75 08                	jne    800ae7 <strcmp+0x20>
		p++, q++;
  800adf:	83 c1 01             	add    $0x1,%ecx
  800ae2:	83 c2 01             	add    $0x1,%edx
  800ae5:	eb ed                	jmp    800ad4 <strcmp+0xd>
	return (int) ((unsigned char) *p - (unsigned char) *q);
  800ae7:	0f b6 c0             	movzbl %al,%eax
  800aea:	0f b6 12             	movzbl (%edx),%edx
  800aed:	29 d0                	sub    %edx,%eax
}
  800aef:	5d                   	pop    %ebp
  800af0:	c3                   	ret    

00800af1 <strncmp>:

int
strncmp(const char *p, const char *q, size_t n)
{
  800af1:	f3 0f 1e fb          	endbr32 
  800af5:	55                   	push   %ebp
  800af6:	89 e5                	mov    %esp,%ebp
  800af8:	53                   	push   %ebx
  800af9:	8b 45 08             	mov    0x8(%ebp),%eax
  800afc:	8b 55 0c             	mov    0xc(%ebp),%edx
  800aff:	89 c3                	mov    %eax,%ebx
  800b01:	03 5d 10             	add    0x10(%ebp),%ebx
	while (n > 0 && *p && *p == *q)
  800b04:	eb 06                	jmp    800b0c <strncmp+0x1b>
		n--, p++, q++;
  800b06:	83 c0 01             	add    $0x1,%eax
  800b09:	83 c2 01             	add    $0x1,%edx
	while (n > 0 && *p && *p == *q)
  800b0c:	39 d8                	cmp    %ebx,%eax
  800b0e:	74 16                	je     800b26 <strncmp+0x35>
  800b10:	0f b6 08             	movzbl (%eax),%ecx
  800b13:	84 c9                	test   %cl,%cl
  800b15:	74 04                	je     800b1b <strncmp+0x2a>
  800b17:	3a 0a                	cmp    (%edx),%cl
  800b19:	74 eb                	je     800b06 <strncmp+0x15>
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
  800b1b:	0f b6 00             	movzbl (%eax),%eax
  800b1e:	0f b6 12             	movzbl (%edx),%edx
  800b21:	29 d0                	sub    %edx,%eax
}
  800b23:	5b                   	pop    %ebx
  800b24:	5d                   	pop    %ebp
  800b25:	c3                   	ret    
		return 0;
  800b26:	b8 00 00 00 00       	mov    $0x0,%eax
  800b2b:	eb f6                	jmp    800b23 <strncmp+0x32>

00800b2d <strchr>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
  800b2d:	f3 0f 1e fb          	endbr32 
  800b31:	55                   	push   %ebp
  800b32:	89 e5                	mov    %esp,%ebp
  800b34:	8b 45 08             	mov    0x8(%ebp),%eax
  800b37:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800b3b:	0f b6 10             	movzbl (%eax),%edx
  800b3e:	84 d2                	test   %dl,%dl
  800b40:	74 09                	je     800b4b <strchr+0x1e>
		if (*s == c)
  800b42:	38 ca                	cmp    %cl,%dl
  800b44:	74 0a                	je     800b50 <strchr+0x23>
	for (; *s; s++)
  800b46:	83 c0 01             	add    $0x1,%eax
  800b49:	eb f0                	jmp    800b3b <strchr+0xe>
			return (char *) s;
	return 0;
  800b4b:	b8 00 00 00 00       	mov    $0x0,%eax
}
  800b50:	5d                   	pop    %ebp
  800b51:	c3                   	ret    

00800b52 <strfind>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
  800b52:	f3 0f 1e fb          	endbr32 
  800b56:	55                   	push   %ebp
  800b57:	89 e5                	mov    %esp,%ebp
  800b59:	8b 45 08             	mov    0x8(%ebp),%eax
  800b5c:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800b60:	0f b6 10             	movzbl (%eax),%edx
		if (*s == c)
  800b63:	38 ca                	cmp    %cl,%dl
  800b65:	74 09                	je     800b70 <strfind+0x1e>
  800b67:	84 d2                	test   %dl,%dl
  800b69:	74 05                	je     800b70 <strfind+0x1e>
	for (; *s; s++)
  800b6b:	83 c0 01             	add    $0x1,%eax
  800b6e:	eb f0                	jmp    800b60 <strfind+0xe>
			break;
	return (char *) s;
}
  800b70:	5d                   	pop    %ebp
  800b71:	c3                   	ret    

00800b72 <memset>:

#if ASM
void *
memset(void *v, int c, size_t n)
{
  800b72:	f3 0f 1e fb          	endbr32 
  800b76:	55                   	push   %ebp
  800b77:	89 e5                	mov    %esp,%ebp
  800b79:	57                   	push   %edi
  800b7a:	56                   	push   %esi
  800b7b:	53                   	push   %ebx
  800b7c:	8b 7d 08             	mov    0x8(%ebp),%edi
  800b7f:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *p;

	if (n == 0)
  800b82:	85 c9                	test   %ecx,%ecx
  800b84:	74 31                	je     800bb7 <memset+0x45>
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800b86:	89 f8                	mov    %edi,%eax
  800b88:	09 c8                	or     %ecx,%eax
  800b8a:	a8 03                	test   $0x3,%al
  800b8c:	75 23                	jne    800bb1 <memset+0x3f>
		c &= 0xFF;
  800b8e:	0f b6 55 0c          	movzbl 0xc(%ebp),%edx
		c = (c<<24)|(c<<16)|(c<<8)|c;
  800b92:	89 d3                	mov    %edx,%ebx
  800b94:	c1 e3 08             	shl    $0x8,%ebx
  800b97:	89 d0                	mov    %edx,%eax
  800b99:	c1 e0 18             	shl    $0x18,%eax
  800b9c:	89 d6                	mov    %edx,%esi
  800b9e:	c1 e6 10             	shl    $0x10,%esi
  800ba1:	09 f0                	or     %esi,%eax
  800ba3:	09 c2                	or     %eax,%edx
  800ba5:	09 da                	or     %ebx,%edx
		asm volatile("cld; rep stosl\n"
			:: "D" (v), "a" (c), "c" (n/4)
  800ba7:	c1 e9 02             	shr    $0x2,%ecx
		asm volatile("cld; rep stosl\n"
  800baa:	89 d0                	mov    %edx,%eax
  800bac:	fc                   	cld    
  800bad:	f3 ab                	rep stos %eax,%es:(%edi)
  800baf:	eb 06                	jmp    800bb7 <memset+0x45>
			: "cc", "memory");
	} else
		asm volatile("cld; rep stosb\n"
  800bb1:	8b 45 0c             	mov    0xc(%ebp),%eax
  800bb4:	fc                   	cld    
  800bb5:	f3 aa                	rep stos %al,%es:(%edi)
			:: "D" (v), "a" (c), "c" (n)
			: "cc", "memory");
	return v;
}
  800bb7:	89 f8                	mov    %edi,%eax
  800bb9:	5b                   	pop    %ebx
  800bba:	5e                   	pop    %esi
  800bbb:	5f                   	pop    %edi
  800bbc:	5d                   	pop    %ebp
  800bbd:	c3                   	ret    

00800bbe <memmove>:

void *
memmove(void *dst, const void *src, size_t n)
{
  800bbe:	f3 0f 1e fb          	endbr32 
  800bc2:	55                   	push   %ebp
  800bc3:	89 e5                	mov    %esp,%ebp
  800bc5:	57                   	push   %edi
  800bc6:	56                   	push   %esi
  800bc7:	8b 45 08             	mov    0x8(%ebp),%eax
  800bca:	8b 75 0c             	mov    0xc(%ebp),%esi
  800bcd:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const char *s;
	char *d;

	s = src;
	d = dst;
	if (s < d && s + n > d) {
  800bd0:	39 c6                	cmp    %eax,%esi
  800bd2:	73 32                	jae    800c06 <memmove+0x48>
  800bd4:	8d 14 0e             	lea    (%esi,%ecx,1),%edx
  800bd7:	39 c2                	cmp    %eax,%edx
  800bd9:	76 2b                	jbe    800c06 <memmove+0x48>
		s += n;
		d += n;
  800bdb:	8d 3c 08             	lea    (%eax,%ecx,1),%edi
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800bde:	89 fe                	mov    %edi,%esi
  800be0:	09 ce                	or     %ecx,%esi
  800be2:	09 d6                	or     %edx,%esi
  800be4:	f7 c6 03 00 00 00    	test   $0x3,%esi
  800bea:	75 0e                	jne    800bfa <memmove+0x3c>
			asm volatile("std; rep movsl\n"
				:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
  800bec:	83 ef 04             	sub    $0x4,%edi
  800bef:	8d 72 fc             	lea    -0x4(%edx),%esi
  800bf2:	c1 e9 02             	shr    $0x2,%ecx
			asm volatile("std; rep movsl\n"
  800bf5:	fd                   	std    
  800bf6:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
  800bf8:	eb 09                	jmp    800c03 <memmove+0x45>
		else
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
  800bfa:	83 ef 01             	sub    $0x1,%edi
  800bfd:	8d 72 ff             	lea    -0x1(%edx),%esi
			asm volatile("std; rep movsb\n"
  800c00:	fd                   	std    
  800c01:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
  800c03:	fc                   	cld    
  800c04:	eb 1a                	jmp    800c20 <memmove+0x62>
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800c06:	89 c2                	mov    %eax,%edx
  800c08:	09 ca                	or     %ecx,%edx
  800c0a:	09 f2                	or     %esi,%edx
  800c0c:	f6 c2 03             	test   $0x3,%dl
  800c0f:	75 0a                	jne    800c1b <memmove+0x5d>
			asm volatile("cld; rep movsl\n"
				:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
  800c11:	c1 e9 02             	shr    $0x2,%ecx
			asm volatile("cld; rep movsl\n"
  800c14:	89 c7                	mov    %eax,%edi
  800c16:	fc                   	cld    
  800c17:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
  800c19:	eb 05                	jmp    800c20 <memmove+0x62>
		else
			asm volatile("cld; rep movsb\n"
  800c1b:	89 c7                	mov    %eax,%edi
  800c1d:	fc                   	cld    
  800c1e:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
	}
	return dst;
}
  800c20:	5e                   	pop    %esi
  800c21:	5f                   	pop    %edi
  800c22:	5d                   	pop    %ebp
  800c23:	c3                   	ret    

00800c24 <memcpy>:
}
#endif

void *
memcpy(void *dst, const void *src, size_t n)
{
  800c24:	f3 0f 1e fb          	endbr32 
  800c28:	55                   	push   %ebp
  800c29:	89 e5                	mov    %esp,%ebp
  800c2b:	83 ec 0c             	sub    $0xc,%esp
	return memmove(dst, src, n);
  800c2e:	ff 75 10             	pushl  0x10(%ebp)
  800c31:	ff 75 0c             	pushl  0xc(%ebp)
  800c34:	ff 75 08             	pushl  0x8(%ebp)
  800c37:	e8 82 ff ff ff       	call   800bbe <memmove>
}
  800c3c:	c9                   	leave  
  800c3d:	c3                   	ret    

00800c3e <memcmp>:

int
memcmp(const void *v1, const void *v2, size_t n)
{
  800c3e:	f3 0f 1e fb          	endbr32 
  800c42:	55                   	push   %ebp
  800c43:	89 e5                	mov    %esp,%ebp
  800c45:	56                   	push   %esi
  800c46:	53                   	push   %ebx
  800c47:	8b 45 08             	mov    0x8(%ebp),%eax
  800c4a:	8b 55 0c             	mov    0xc(%ebp),%edx
  800c4d:	89 c6                	mov    %eax,%esi
  800c4f:	03 75 10             	add    0x10(%ebp),%esi
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800c52:	39 f0                	cmp    %esi,%eax
  800c54:	74 1c                	je     800c72 <memcmp+0x34>
		if (*s1 != *s2)
  800c56:	0f b6 08             	movzbl (%eax),%ecx
  800c59:	0f b6 1a             	movzbl (%edx),%ebx
  800c5c:	38 d9                	cmp    %bl,%cl
  800c5e:	75 08                	jne    800c68 <memcmp+0x2a>
			return (int) *s1 - (int) *s2;
		s1++, s2++;
  800c60:	83 c0 01             	add    $0x1,%eax
  800c63:	83 c2 01             	add    $0x1,%edx
  800c66:	eb ea                	jmp    800c52 <memcmp+0x14>
			return (int) *s1 - (int) *s2;
  800c68:	0f b6 c1             	movzbl %cl,%eax
  800c6b:	0f b6 db             	movzbl %bl,%ebx
  800c6e:	29 d8                	sub    %ebx,%eax
  800c70:	eb 05                	jmp    800c77 <memcmp+0x39>
	}

	return 0;
  800c72:	b8 00 00 00 00       	mov    $0x0,%eax
}
  800c77:	5b                   	pop    %ebx
  800c78:	5e                   	pop    %esi
  800c79:	5d                   	pop    %ebp
  800c7a:	c3                   	ret    

00800c7b <memfind>:

void *
memfind(const void *s, int c, size_t n)
{
  800c7b:	f3 0f 1e fb          	endbr32 
  800c7f:	55                   	push   %ebp
  800c80:	89 e5                	mov    %esp,%ebp
  800c82:	8b 45 08             	mov    0x8(%ebp),%eax
  800c85:	8b 4d 0c             	mov    0xc(%ebp),%ecx
	const void *ends = (const char *) s + n;
  800c88:	89 c2                	mov    %eax,%edx
  800c8a:	03 55 10             	add    0x10(%ebp),%edx
	for (; s < ends; s++)
  800c8d:	39 d0                	cmp    %edx,%eax
  800c8f:	73 09                	jae    800c9a <memfind+0x1f>
		if (*(const unsigned char *) s == (unsigned char) c)
  800c91:	38 08                	cmp    %cl,(%eax)
  800c93:	74 05                	je     800c9a <memfind+0x1f>
	for (; s < ends; s++)
  800c95:	83 c0 01             	add    $0x1,%eax
  800c98:	eb f3                	jmp    800c8d <memfind+0x12>
			break;
	return (void *) s;
}
  800c9a:	5d                   	pop    %ebp
  800c9b:	c3                   	ret    

00800c9c <strtol>:

long
strtol(const char *s, char **endptr, int base)
{
  800c9c:	f3 0f 1e fb          	endbr32 
  800ca0:	55                   	push   %ebp
  800ca1:	89 e5                	mov    %esp,%ebp
  800ca3:	57                   	push   %edi
  800ca4:	56                   	push   %esi
  800ca5:	53                   	push   %ebx
  800ca6:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800ca9:	8b 5d 10             	mov    0x10(%ebp),%ebx
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800cac:	eb 03                	jmp    800cb1 <strtol+0x15>
		s++;
  800cae:	83 c1 01             	add    $0x1,%ecx
	while (*s == ' ' || *s == '\t')
  800cb1:	0f b6 01             	movzbl (%ecx),%eax
  800cb4:	3c 20                	cmp    $0x20,%al
  800cb6:	74 f6                	je     800cae <strtol+0x12>
  800cb8:	3c 09                	cmp    $0x9,%al
  800cba:	74 f2                	je     800cae <strtol+0x12>

	// plus/minus sign
	if (*s == '+')
  800cbc:	3c 2b                	cmp    $0x2b,%al
  800cbe:	74 2a                	je     800cea <strtol+0x4e>
	int neg = 0;
  800cc0:	bf 00 00 00 00       	mov    $0x0,%edi
		s++;
	else if (*s == '-')
  800cc5:	3c 2d                	cmp    $0x2d,%al
  800cc7:	74 2b                	je     800cf4 <strtol+0x58>
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800cc9:	f7 c3 ef ff ff ff    	test   $0xffffffef,%ebx
  800ccf:	75 0f                	jne    800ce0 <strtol+0x44>
  800cd1:	80 39 30             	cmpb   $0x30,(%ecx)
  800cd4:	74 28                	je     800cfe <strtol+0x62>
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
		s++, base = 8;
	else if (base == 0)
		base = 10;
  800cd6:	85 db                	test   %ebx,%ebx
  800cd8:	b8 0a 00 00 00       	mov    $0xa,%eax
  800cdd:	0f 44 d8             	cmove  %eax,%ebx
  800ce0:	b8 00 00 00 00       	mov    $0x0,%eax
  800ce5:	89 5d 10             	mov    %ebx,0x10(%ebp)
  800ce8:	eb 46                	jmp    800d30 <strtol+0x94>
		s++;
  800cea:	83 c1 01             	add    $0x1,%ecx
	int neg = 0;
  800ced:	bf 00 00 00 00       	mov    $0x0,%edi
  800cf2:	eb d5                	jmp    800cc9 <strtol+0x2d>
		s++, neg = 1;
  800cf4:	83 c1 01             	add    $0x1,%ecx
  800cf7:	bf 01 00 00 00       	mov    $0x1,%edi
  800cfc:	eb cb                	jmp    800cc9 <strtol+0x2d>
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800cfe:	80 79 01 78          	cmpb   $0x78,0x1(%ecx)
  800d02:	74 0e                	je     800d12 <strtol+0x76>
	else if (base == 0 && s[0] == '0')
  800d04:	85 db                	test   %ebx,%ebx
  800d06:	75 d8                	jne    800ce0 <strtol+0x44>
		s++, base = 8;
  800d08:	83 c1 01             	add    $0x1,%ecx
  800d0b:	bb 08 00 00 00       	mov    $0x8,%ebx
  800d10:	eb ce                	jmp    800ce0 <strtol+0x44>
		s += 2, base = 16;
  800d12:	83 c1 02             	add    $0x2,%ecx
  800d15:	bb 10 00 00 00       	mov    $0x10,%ebx
  800d1a:	eb c4                	jmp    800ce0 <strtol+0x44>
	// digits
	while (1) {
		int dig;

		if (*s >= '0' && *s <= '9')
			dig = *s - '0';
  800d1c:	0f be d2             	movsbl %dl,%edx
  800d1f:	83 ea 30             	sub    $0x30,%edx
			dig = *s - 'a' + 10;
		else if (*s >= 'A' && *s <= 'Z')
			dig = *s - 'A' + 10;
		else
			break;
		if (dig >= base)
  800d22:	3b 55 10             	cmp    0x10(%ebp),%edx
  800d25:	7d 3a                	jge    800d61 <strtol+0xc5>
			break;
		s++, val = (val * base) + dig;
  800d27:	83 c1 01             	add    $0x1,%ecx
  800d2a:	0f af 45 10          	imul   0x10(%ebp),%eax
  800d2e:	01 d0                	add    %edx,%eax
		if (*s >= '0' && *s <= '9')
  800d30:	0f b6 11             	movzbl (%ecx),%edx
  800d33:	8d 72 d0             	lea    -0x30(%edx),%esi
  800d36:	89 f3                	mov    %esi,%ebx
  800d38:	80 fb 09             	cmp    $0x9,%bl
  800d3b:	76 df                	jbe    800d1c <strtol+0x80>
		else if (*s >= 'a' && *s <= 'z')
  800d3d:	8d 72 9f             	lea    -0x61(%edx),%esi
  800d40:	89 f3                	mov    %esi,%ebx
  800d42:	80 fb 19             	cmp    $0x19,%bl
  800d45:	77 08                	ja     800d4f <strtol+0xb3>
			dig = *s - 'a' + 10;
  800d47:	0f be d2             	movsbl %dl,%edx
  800d4a:	83 ea 57             	sub    $0x57,%edx
  800d4d:	eb d3                	jmp    800d22 <strtol+0x86>
		else if (*s >= 'A' && *s <= 'Z')
  800d4f:	8d 72 bf             	lea    -0x41(%edx),%esi
  800d52:	89 f3                	mov    %esi,%ebx
  800d54:	80 fb 19             	cmp    $0x19,%bl
  800d57:	77 08                	ja     800d61 <strtol+0xc5>
			dig = *s - 'A' + 10;
  800d59:	0f be d2             	movsbl %dl,%edx
  800d5c:	83 ea 37             	sub    $0x37,%edx
  800d5f:	eb c1                	jmp    800d22 <strtol+0x86>
		// we don't properly detect overflow!
	}

	if (endptr)
  800d61:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  800d65:	74 05                	je     800d6c <strtol+0xd0>
		*endptr = (char *) s;
  800d67:	8b 75 0c             	mov    0xc(%ebp),%esi
  800d6a:	89 0e                	mov    %ecx,(%esi)
	return (neg ? -val : val);
  800d6c:	89 c2                	mov    %eax,%edx
  800d6e:	f7 da                	neg    %edx
  800d70:	85 ff                	test   %edi,%edi
  800d72:	0f 45 c2             	cmovne %edx,%eax
}
  800d75:	5b                   	pop    %ebx
  800d76:	5e                   	pop    %esi
  800d77:	5f                   	pop    %edi
  800d78:	5d                   	pop    %ebp
  800d79:	c3                   	ret    

00800d7a <sys_cputs>:
	return ret;
}

void
sys_cputs(const char *s, size_t len)
{
  800d7a:	f3 0f 1e fb          	endbr32 
  800d7e:	55                   	push   %ebp
  800d7f:	89 e5                	mov    %esp,%ebp
  800d81:	57                   	push   %edi
  800d82:	56                   	push   %esi
  800d83:	53                   	push   %ebx
	asm volatile("int %1\n"
  800d84:	b8 00 00 00 00       	mov    $0x0,%eax
  800d89:	8b 55 08             	mov    0x8(%ebp),%edx
  800d8c:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800d8f:	89 c3                	mov    %eax,%ebx
  800d91:	89 c7                	mov    %eax,%edi
  800d93:	89 c6                	mov    %eax,%esi
  800d95:	cd 30                	int    $0x30
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
  800d97:	5b                   	pop    %ebx
  800d98:	5e                   	pop    %esi
  800d99:	5f                   	pop    %edi
  800d9a:	5d                   	pop    %ebp
  800d9b:	c3                   	ret    

00800d9c <sys_cgetc>:

int
sys_cgetc(void)
{
  800d9c:	f3 0f 1e fb          	endbr32 
  800da0:	55                   	push   %ebp
  800da1:	89 e5                	mov    %esp,%ebp
  800da3:	57                   	push   %edi
  800da4:	56                   	push   %esi
  800da5:	53                   	push   %ebx
	asm volatile("int %1\n"
  800da6:	ba 00 00 00 00       	mov    $0x0,%edx
  800dab:	b8 01 00 00 00       	mov    $0x1,%eax
  800db0:	89 d1                	mov    %edx,%ecx
  800db2:	89 d3                	mov    %edx,%ebx
  800db4:	89 d7                	mov    %edx,%edi
  800db6:	89 d6                	mov    %edx,%esi
  800db8:	cd 30                	int    $0x30
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
  800dba:	5b                   	pop    %ebx
  800dbb:	5e                   	pop    %esi
  800dbc:	5f                   	pop    %edi
  800dbd:	5d                   	pop    %ebp
  800dbe:	c3                   	ret    

00800dbf <sys_env_destroy>:

int
sys_env_destroy(envid_t envid)
{
  800dbf:	f3 0f 1e fb          	endbr32 
  800dc3:	55                   	push   %ebp
  800dc4:	89 e5                	mov    %esp,%ebp
  800dc6:	57                   	push   %edi
  800dc7:	56                   	push   %esi
  800dc8:	53                   	push   %ebx
  800dc9:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  800dcc:	b9 00 00 00 00       	mov    $0x0,%ecx
  800dd1:	8b 55 08             	mov    0x8(%ebp),%edx
  800dd4:	b8 03 00 00 00       	mov    $0x3,%eax
  800dd9:	89 cb                	mov    %ecx,%ebx
  800ddb:	89 cf                	mov    %ecx,%edi
  800ddd:	89 ce                	mov    %ecx,%esi
  800ddf:	cd 30                	int    $0x30
	if(check && ret > 0)
  800de1:	85 c0                	test   %eax,%eax
  800de3:	7f 08                	jg     800ded <sys_env_destroy+0x2e>
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
  800de5:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800de8:	5b                   	pop    %ebx
  800de9:	5e                   	pop    %esi
  800dea:	5f                   	pop    %edi
  800deb:	5d                   	pop    %ebp
  800dec:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  800ded:	83 ec 0c             	sub    $0xc,%esp
  800df0:	50                   	push   %eax
  800df1:	6a 03                	push   $0x3
  800df3:	68 1f 2a 80 00       	push   $0x802a1f
  800df8:	6a 23                	push   $0x23
  800dfa:	68 3c 2a 80 00       	push   $0x802a3c
  800dff:	e8 44 f5 ff ff       	call   800348 <_panic>

00800e04 <sys_getenvid>:

envid_t
sys_getenvid(void)
{
  800e04:	f3 0f 1e fb          	endbr32 
  800e08:	55                   	push   %ebp
  800e09:	89 e5                	mov    %esp,%ebp
  800e0b:	57                   	push   %edi
  800e0c:	56                   	push   %esi
  800e0d:	53                   	push   %ebx
	asm volatile("int %1\n"
  800e0e:	ba 00 00 00 00       	mov    $0x0,%edx
  800e13:	b8 02 00 00 00       	mov    $0x2,%eax
  800e18:	89 d1                	mov    %edx,%ecx
  800e1a:	89 d3                	mov    %edx,%ebx
  800e1c:	89 d7                	mov    %edx,%edi
  800e1e:	89 d6                	mov    %edx,%esi
  800e20:	cd 30                	int    $0x30
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
  800e22:	5b                   	pop    %ebx
  800e23:	5e                   	pop    %esi
  800e24:	5f                   	pop    %edi
  800e25:	5d                   	pop    %ebp
  800e26:	c3                   	ret    

00800e27 <sys_yield>:

void
sys_yield(void)
{
  800e27:	f3 0f 1e fb          	endbr32 
  800e2b:	55                   	push   %ebp
  800e2c:	89 e5                	mov    %esp,%ebp
  800e2e:	57                   	push   %edi
  800e2f:	56                   	push   %esi
  800e30:	53                   	push   %ebx
	asm volatile("int %1\n"
  800e31:	ba 00 00 00 00       	mov    $0x0,%edx
  800e36:	b8 0b 00 00 00       	mov    $0xb,%eax
  800e3b:	89 d1                	mov    %edx,%ecx
  800e3d:	89 d3                	mov    %edx,%ebx
  800e3f:	89 d7                	mov    %edx,%edi
  800e41:	89 d6                	mov    %edx,%esi
  800e43:	cd 30                	int    $0x30
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
  800e45:	5b                   	pop    %ebx
  800e46:	5e                   	pop    %esi
  800e47:	5f                   	pop    %edi
  800e48:	5d                   	pop    %ebp
  800e49:	c3                   	ret    

00800e4a <sys_page_alloc>:

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
  800e4a:	f3 0f 1e fb          	endbr32 
  800e4e:	55                   	push   %ebp
  800e4f:	89 e5                	mov    %esp,%ebp
  800e51:	57                   	push   %edi
  800e52:	56                   	push   %esi
  800e53:	53                   	push   %ebx
  800e54:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  800e57:	be 00 00 00 00       	mov    $0x0,%esi
  800e5c:	8b 55 08             	mov    0x8(%ebp),%edx
  800e5f:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800e62:	b8 04 00 00 00       	mov    $0x4,%eax
  800e67:	8b 5d 10             	mov    0x10(%ebp),%ebx
  800e6a:	89 f7                	mov    %esi,%edi
  800e6c:	cd 30                	int    $0x30
	if(check && ret > 0)
  800e6e:	85 c0                	test   %eax,%eax
  800e70:	7f 08                	jg     800e7a <sys_page_alloc+0x30>
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
  800e72:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800e75:	5b                   	pop    %ebx
  800e76:	5e                   	pop    %esi
  800e77:	5f                   	pop    %edi
  800e78:	5d                   	pop    %ebp
  800e79:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  800e7a:	83 ec 0c             	sub    $0xc,%esp
  800e7d:	50                   	push   %eax
  800e7e:	6a 04                	push   $0x4
  800e80:	68 1f 2a 80 00       	push   $0x802a1f
  800e85:	6a 23                	push   $0x23
  800e87:	68 3c 2a 80 00       	push   $0x802a3c
  800e8c:	e8 b7 f4 ff ff       	call   800348 <_panic>

00800e91 <sys_page_map>:

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
  800e91:	f3 0f 1e fb          	endbr32 
  800e95:	55                   	push   %ebp
  800e96:	89 e5                	mov    %esp,%ebp
  800e98:	57                   	push   %edi
  800e99:	56                   	push   %esi
  800e9a:	53                   	push   %ebx
  800e9b:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  800e9e:	8b 55 08             	mov    0x8(%ebp),%edx
  800ea1:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800ea4:	b8 05 00 00 00       	mov    $0x5,%eax
  800ea9:	8b 5d 10             	mov    0x10(%ebp),%ebx
  800eac:	8b 7d 14             	mov    0x14(%ebp),%edi
  800eaf:	8b 75 18             	mov    0x18(%ebp),%esi
  800eb2:	cd 30                	int    $0x30
	if(check && ret > 0)
  800eb4:	85 c0                	test   %eax,%eax
  800eb6:	7f 08                	jg     800ec0 <sys_page_map+0x2f>
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
  800eb8:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800ebb:	5b                   	pop    %ebx
  800ebc:	5e                   	pop    %esi
  800ebd:	5f                   	pop    %edi
  800ebe:	5d                   	pop    %ebp
  800ebf:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  800ec0:	83 ec 0c             	sub    $0xc,%esp
  800ec3:	50                   	push   %eax
  800ec4:	6a 05                	push   $0x5
  800ec6:	68 1f 2a 80 00       	push   $0x802a1f
  800ecb:	6a 23                	push   $0x23
  800ecd:	68 3c 2a 80 00       	push   $0x802a3c
  800ed2:	e8 71 f4 ff ff       	call   800348 <_panic>

00800ed7 <sys_page_unmap>:

int
sys_page_unmap(envid_t envid, void *va)
{
  800ed7:	f3 0f 1e fb          	endbr32 
  800edb:	55                   	push   %ebp
  800edc:	89 e5                	mov    %esp,%ebp
  800ede:	57                   	push   %edi
  800edf:	56                   	push   %esi
  800ee0:	53                   	push   %ebx
  800ee1:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  800ee4:	bb 00 00 00 00       	mov    $0x0,%ebx
  800ee9:	8b 55 08             	mov    0x8(%ebp),%edx
  800eec:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800eef:	b8 06 00 00 00       	mov    $0x6,%eax
  800ef4:	89 df                	mov    %ebx,%edi
  800ef6:	89 de                	mov    %ebx,%esi
  800ef8:	cd 30                	int    $0x30
	if(check && ret > 0)
  800efa:	85 c0                	test   %eax,%eax
  800efc:	7f 08                	jg     800f06 <sys_page_unmap+0x2f>
	return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
  800efe:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800f01:	5b                   	pop    %ebx
  800f02:	5e                   	pop    %esi
  800f03:	5f                   	pop    %edi
  800f04:	5d                   	pop    %ebp
  800f05:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  800f06:	83 ec 0c             	sub    $0xc,%esp
  800f09:	50                   	push   %eax
  800f0a:	6a 06                	push   $0x6
  800f0c:	68 1f 2a 80 00       	push   $0x802a1f
  800f11:	6a 23                	push   $0x23
  800f13:	68 3c 2a 80 00       	push   $0x802a3c
  800f18:	e8 2b f4 ff ff       	call   800348 <_panic>

00800f1d <sys_env_set_status>:

// sys_exofork is inlined in lib.h

int
sys_env_set_status(envid_t envid, int status)
{
  800f1d:	f3 0f 1e fb          	endbr32 
  800f21:	55                   	push   %ebp
  800f22:	89 e5                	mov    %esp,%ebp
  800f24:	57                   	push   %edi
  800f25:	56                   	push   %esi
  800f26:	53                   	push   %ebx
  800f27:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  800f2a:	bb 00 00 00 00       	mov    $0x0,%ebx
  800f2f:	8b 55 08             	mov    0x8(%ebp),%edx
  800f32:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800f35:	b8 08 00 00 00       	mov    $0x8,%eax
  800f3a:	89 df                	mov    %ebx,%edi
  800f3c:	89 de                	mov    %ebx,%esi
  800f3e:	cd 30                	int    $0x30
	if(check && ret > 0)
  800f40:	85 c0                	test   %eax,%eax
  800f42:	7f 08                	jg     800f4c <sys_env_set_status+0x2f>
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
  800f44:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800f47:	5b                   	pop    %ebx
  800f48:	5e                   	pop    %esi
  800f49:	5f                   	pop    %edi
  800f4a:	5d                   	pop    %ebp
  800f4b:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  800f4c:	83 ec 0c             	sub    $0xc,%esp
  800f4f:	50                   	push   %eax
  800f50:	6a 08                	push   $0x8
  800f52:	68 1f 2a 80 00       	push   $0x802a1f
  800f57:	6a 23                	push   $0x23
  800f59:	68 3c 2a 80 00       	push   $0x802a3c
  800f5e:	e8 e5 f3 ff ff       	call   800348 <_panic>

00800f63 <sys_env_set_trapframe>:

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
  800f63:	f3 0f 1e fb          	endbr32 
  800f67:	55                   	push   %ebp
  800f68:	89 e5                	mov    %esp,%ebp
  800f6a:	57                   	push   %edi
  800f6b:	56                   	push   %esi
  800f6c:	53                   	push   %ebx
  800f6d:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  800f70:	bb 00 00 00 00       	mov    $0x0,%ebx
  800f75:	8b 55 08             	mov    0x8(%ebp),%edx
  800f78:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800f7b:	b8 09 00 00 00       	mov    $0x9,%eax
  800f80:	89 df                	mov    %ebx,%edi
  800f82:	89 de                	mov    %ebx,%esi
  800f84:	cd 30                	int    $0x30
	if(check && ret > 0)
  800f86:	85 c0                	test   %eax,%eax
  800f88:	7f 08                	jg     800f92 <sys_env_set_trapframe+0x2f>
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
  800f8a:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800f8d:	5b                   	pop    %ebx
  800f8e:	5e                   	pop    %esi
  800f8f:	5f                   	pop    %edi
  800f90:	5d                   	pop    %ebp
  800f91:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  800f92:	83 ec 0c             	sub    $0xc,%esp
  800f95:	50                   	push   %eax
  800f96:	6a 09                	push   $0x9
  800f98:	68 1f 2a 80 00       	push   $0x802a1f
  800f9d:	6a 23                	push   $0x23
  800f9f:	68 3c 2a 80 00       	push   $0x802a3c
  800fa4:	e8 9f f3 ff ff       	call   800348 <_panic>

00800fa9 <sys_env_set_pgfault_upcall>:

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
  800fa9:	f3 0f 1e fb          	endbr32 
  800fad:	55                   	push   %ebp
  800fae:	89 e5                	mov    %esp,%ebp
  800fb0:	57                   	push   %edi
  800fb1:	56                   	push   %esi
  800fb2:	53                   	push   %ebx
  800fb3:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  800fb6:	bb 00 00 00 00       	mov    $0x0,%ebx
  800fbb:	8b 55 08             	mov    0x8(%ebp),%edx
  800fbe:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800fc1:	b8 0a 00 00 00       	mov    $0xa,%eax
  800fc6:	89 df                	mov    %ebx,%edi
  800fc8:	89 de                	mov    %ebx,%esi
  800fca:	cd 30                	int    $0x30
	if(check && ret > 0)
  800fcc:	85 c0                	test   %eax,%eax
  800fce:	7f 08                	jg     800fd8 <sys_env_set_pgfault_upcall+0x2f>
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
  800fd0:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800fd3:	5b                   	pop    %ebx
  800fd4:	5e                   	pop    %esi
  800fd5:	5f                   	pop    %edi
  800fd6:	5d                   	pop    %ebp
  800fd7:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  800fd8:	83 ec 0c             	sub    $0xc,%esp
  800fdb:	50                   	push   %eax
  800fdc:	6a 0a                	push   $0xa
  800fde:	68 1f 2a 80 00       	push   $0x802a1f
  800fe3:	6a 23                	push   $0x23
  800fe5:	68 3c 2a 80 00       	push   $0x802a3c
  800fea:	e8 59 f3 ff ff       	call   800348 <_panic>

00800fef <sys_ipc_try_send>:

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
  800fef:	f3 0f 1e fb          	endbr32 
  800ff3:	55                   	push   %ebp
  800ff4:	89 e5                	mov    %esp,%ebp
  800ff6:	57                   	push   %edi
  800ff7:	56                   	push   %esi
  800ff8:	53                   	push   %ebx
	asm volatile("int %1\n"
  800ff9:	8b 55 08             	mov    0x8(%ebp),%edx
  800ffc:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800fff:	b8 0c 00 00 00       	mov    $0xc,%eax
  801004:	be 00 00 00 00       	mov    $0x0,%esi
  801009:	8b 5d 10             	mov    0x10(%ebp),%ebx
  80100c:	8b 7d 14             	mov    0x14(%ebp),%edi
  80100f:	cd 30                	int    $0x30
	return syscall(SYS_ipc_try_send, 0, envid, value, (uint32_t) srcva, perm, 0);
}
  801011:	5b                   	pop    %ebx
  801012:	5e                   	pop    %esi
  801013:	5f                   	pop    %edi
  801014:	5d                   	pop    %ebp
  801015:	c3                   	ret    

00801016 <sys_ipc_recv>:

int
sys_ipc_recv(void *dstva)
{
  801016:	f3 0f 1e fb          	endbr32 
  80101a:	55                   	push   %ebp
  80101b:	89 e5                	mov    %esp,%ebp
  80101d:	57                   	push   %edi
  80101e:	56                   	push   %esi
  80101f:	53                   	push   %ebx
  801020:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  801023:	b9 00 00 00 00       	mov    $0x0,%ecx
  801028:	8b 55 08             	mov    0x8(%ebp),%edx
  80102b:	b8 0d 00 00 00       	mov    $0xd,%eax
  801030:	89 cb                	mov    %ecx,%ebx
  801032:	89 cf                	mov    %ecx,%edi
  801034:	89 ce                	mov    %ecx,%esi
  801036:	cd 30                	int    $0x30
	if(check && ret > 0)
  801038:	85 c0                	test   %eax,%eax
  80103a:	7f 08                	jg     801044 <sys_ipc_recv+0x2e>
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
  80103c:	8d 65 f4             	lea    -0xc(%ebp),%esp
  80103f:	5b                   	pop    %ebx
  801040:	5e                   	pop    %esi
  801041:	5f                   	pop    %edi
  801042:	5d                   	pop    %ebp
  801043:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  801044:	83 ec 0c             	sub    $0xc,%esp
  801047:	50                   	push   %eax
  801048:	6a 0d                	push   $0xd
  80104a:	68 1f 2a 80 00       	push   $0x802a1f
  80104f:	6a 23                	push   $0x23
  801051:	68 3c 2a 80 00       	push   $0x802a3c
  801056:	e8 ed f2 ff ff       	call   800348 <_panic>

0080105b <pgfault>:
// Custom page fault handler - if faulting page is copy-on-write,
// map in our own private writable copy.
//
static void
pgfault(struct UTrapframe *utf)
{
  80105b:	f3 0f 1e fb          	endbr32 
  80105f:	55                   	push   %ebp
  801060:	89 e5                	mov    %esp,%ebp
  801062:	56                   	push   %esi
  801063:	53                   	push   %ebx
  801064:	8b 45 08             	mov    0x8(%ebp),%eax
	void *addr = (void *) utf->utf_fault_va;
  801067:	8b 18                	mov    (%eax),%ebx
	/*
	将父进程空间中所有可以写的页表的部分全部标记为可读且COW【因此读取的时候不会进入pgfault，但是写的时候会触发pgfault】。
	而当父进程或者子进程任意一个发生了写的时候，因为页表现在都是不可写的，所以会触发异常，进入到我们设定的page fault处理例程，
	当检测到是对COW页的写操作的情况下，就可以将要写入的页的内容全部拷贝一份，重新映射。
	*/
    if (!((err & FEC_WR) && (uvpd[PDX(addr)] & PTE_P) && 
  801069:	f6 40 04 02          	testb  $0x2,0x4(%eax)
  80106d:	0f 84 b2 00 00 00    	je     801125 <pgfault+0xca>
  801073:	89 d8                	mov    %ebx,%eax
  801075:	c1 e8 16             	shr    $0x16,%eax
  801078:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  80107f:	a8 01                	test   $0x1,%al
  801081:	0f 84 9e 00 00 00    	je     801125 <pgfault+0xca>
			(uvpt[PGNUM(addr)] & PTE_P) && (uvpt[PGNUM(addr)] & PTE_COW)))
  801087:	89 d8                	mov    %ebx,%eax
  801089:	c1 e8 0c             	shr    $0xc,%eax
  80108c:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
    if (!((err & FEC_WR) && (uvpd[PDX(addr)] & PTE_P) && 
  801093:	f6 c2 01             	test   $0x1,%dl
  801096:	0f 84 89 00 00 00    	je     801125 <pgfault+0xca>
			(uvpt[PGNUM(addr)] & PTE_P) && (uvpt[PGNUM(addr)] & PTE_COW)))
  80109c:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
    if (!((err & FEC_WR) && (uvpd[PDX(addr)] & PTE_P) && 
  8010a3:	f6 c4 08             	test   $0x8,%ah
  8010a6:	74 7d                	je     801125 <pgfault+0xca>
                panic("pgfault: it's not writable or attempt to access a non-cow page!");
	//为该进程分配新的页面。
	envid_t envid=sys_getenvid();
  8010a8:	e8 57 fd ff ff       	call   800e04 <sys_getenvid>
  8010ad:	89 c6                	mov    %eax,%esi
	r=sys_page_alloc(envid,(void*)PFTEMP,PTE_P|PTE_U|PTE_W);
  8010af:	83 ec 04             	sub    $0x4,%esp
  8010b2:	6a 07                	push   $0x7
  8010b4:	68 00 f0 7f 00       	push   $0x7ff000
  8010b9:	50                   	push   %eax
  8010ba:	e8 8b fd ff ff       	call   800e4a <sys_page_alloc>
	if(r<0){
  8010bf:	83 c4 10             	add    $0x10,%esp
  8010c2:	85 c0                	test   %eax,%eax
  8010c4:	78 73                	js     801139 <pgfault+0xde>
		 panic("pgfault: page allocation failed %e", r);
	}
	//解开了我的疑惑，为什么随着fork页空间会逐渐发生偏移。
	//迁移数据过去。
	addr=ROUNDDOWN(addr,PGSIZE);
  8010c6:	81 e3 00 f0 ff ff    	and    $0xfffff000,%ebx
	//拷贝内容。
	memmove(PFTEMP,addr,PGSIZE);
  8010cc:	83 ec 04             	sub    $0x4,%esp
  8010cf:	68 00 10 00 00       	push   $0x1000
  8010d4:	53                   	push   %ebx
  8010d5:	68 00 f0 7f 00       	push   $0x7ff000
  8010da:	e8 df fa ff ff       	call   800bbe <memmove>
	//解除和addr的映射关系。
	r=sys_page_unmap(envid,(void*)addr);
  8010df:	83 c4 08             	add    $0x8,%esp
  8010e2:	53                   	push   %ebx
  8010e3:	56                   	push   %esi
  8010e4:	e8 ee fd ff ff       	call   800ed7 <sys_page_unmap>
	if(r<0)
  8010e9:	83 c4 10             	add    $0x10,%esp
  8010ec:	85 c0                	test   %eax,%eax
  8010ee:	78 5b                	js     80114b <pgfault+0xf0>
	panic("pgfault: page unmap failed %e", r);
	r=sys_page_map(envid,PFTEMP,envid,addr,PTE_P|PTE_U|PTE_W);
  8010f0:	83 ec 0c             	sub    $0xc,%esp
  8010f3:	6a 07                	push   $0x7
  8010f5:	53                   	push   %ebx
  8010f6:	56                   	push   %esi
  8010f7:	68 00 f0 7f 00       	push   $0x7ff000
  8010fc:	56                   	push   %esi
  8010fd:	e8 8f fd ff ff       	call   800e91 <sys_page_map>
	if(r<0)
  801102:	83 c4 20             	add    $0x20,%esp
  801105:	85 c0                	test   %eax,%eax
  801107:	78 54                	js     80115d <pgfault+0x102>
	panic("pgfault: page map failed %e", r);
	r=sys_page_unmap(envid,PFTEMP);
  801109:	83 ec 08             	sub    $0x8,%esp
  80110c:	68 00 f0 7f 00       	push   $0x7ff000
  801111:	56                   	push   %esi
  801112:	e8 c0 fd ff ff       	call   800ed7 <sys_page_unmap>
	if(r<0)
  801117:	83 c4 10             	add    $0x10,%esp
  80111a:	85 c0                	test   %eax,%eax
  80111c:	78 51                	js     80116f <pgfault+0x114>
	panic("pgfault: page unmap failed %e", r);
}
  80111e:	8d 65 f8             	lea    -0x8(%ebp),%esp
  801121:	5b                   	pop    %ebx
  801122:	5e                   	pop    %esi
  801123:	5d                   	pop    %ebp
  801124:	c3                   	ret    
                panic("pgfault: it's not writable or attempt to access a non-cow page!");
  801125:	83 ec 04             	sub    $0x4,%esp
  801128:	68 4c 2a 80 00       	push   $0x802a4c
  80112d:	6a 2c                	push   $0x2c
  80112f:	68 fb 2a 80 00       	push   $0x802afb
  801134:	e8 0f f2 ff ff       	call   800348 <_panic>
		 panic("pgfault: page allocation failed %e", r);
  801139:	50                   	push   %eax
  80113a:	68 8c 2a 80 00       	push   $0x802a8c
  80113f:	6a 31                	push   $0x31
  801141:	68 fb 2a 80 00       	push   $0x802afb
  801146:	e8 fd f1 ff ff       	call   800348 <_panic>
	panic("pgfault: page unmap failed %e", r);
  80114b:	50                   	push   %eax
  80114c:	68 06 2b 80 00       	push   $0x802b06
  801151:	6a 3b                	push   $0x3b
  801153:	68 fb 2a 80 00       	push   $0x802afb
  801158:	e8 eb f1 ff ff       	call   800348 <_panic>
	panic("pgfault: page map failed %e", r);
  80115d:	50                   	push   %eax
  80115e:	68 24 2b 80 00       	push   $0x802b24
  801163:	6a 3e                	push   $0x3e
  801165:	68 fb 2a 80 00       	push   $0x802afb
  80116a:	e8 d9 f1 ff ff       	call   800348 <_panic>
	panic("pgfault: page unmap failed %e", r);
  80116f:	50                   	push   %eax
  801170:	68 06 2b 80 00       	push   $0x802b06
  801175:	6a 41                	push   $0x41
  801177:	68 fb 2a 80 00       	push   $0x802afb
  80117c:	e8 c7 f1 ff ff       	call   800348 <_panic>

00801181 <fork>:
//   Neither user exception stack should ever be marked copy-on-write,
//   so you must allocate a new page for the child's user exception stack.
//
envid_t
fork(void)
{
  801181:	f3 0f 1e fb          	endbr32 
  801185:	55                   	push   %ebp
  801186:	89 e5                	mov    %esp,%ebp
  801188:	57                   	push   %edi
  801189:	56                   	push   %esi
  80118a:	53                   	push   %ebx
  80118b:	83 ec 28             	sub    $0x28,%esp
	// LAB 4: Your code here.
	envid_t envid;
	uintptr_t pageVa;
	unsigned pn;
	//设置pgfault情况下对应处理的函数。
	set_pgfault_handler(pgfault);
  80118e:	68 5b 10 80 00       	push   $0x80105b
  801193:	e8 9c 0f 00 00       	call   802134 <set_pgfault_handler>
// This must be inlined.  Exercise for reader: why?
static inline envid_t __attribute__((always_inline))
sys_exofork(void)
{
	envid_t ret;
	asm volatile("int %2"
  801198:	b8 07 00 00 00       	mov    $0x7,%eax
  80119d:	cd 30                	int    $0x30
  80119f:	89 c7                	mov    %eax,%edi
  8011a1:	89 45 e4             	mov    %eax,-0x1c(%ebp)
	//首先需要分配一个env，env_alloc是内核态调用的，因此只能去调系统调用对应的函数来请求分配一个环境描述符。
	envid=sys_exofork();
	//分配成功
	if(envid>0){
  8011a4:	83 c4 10             	add    $0x10,%esp
  8011a7:	85 c0                	test   %eax,%eax
  8011a9:	0f 8e 9d 01 00 00    	jle    80134c <fork+0x1cb>
		//接下来应该要拷贝父进程。当然这里让我吃惊的是直接可以调用对应的宏并且并没有去请求父进程。jos系统似乎是把所有的子进程都来源于同一进程，而不是父子继承关系。
		for(pageVa=UTEXT;pageVa<USTACKTOP;pageVa+=PGSIZE){
  8011af:	bb 00 00 80 00       	mov    $0x800000,%ebx
  8011b4:	eb 5b                	jmp    801211 <fork+0x90>
			sys_page_map(0, addr, envid, addr, PTE_SYSCALL);
  8011b6:	83 ec 0c             	sub    $0xc,%esp
  8011b9:	68 07 0e 00 00       	push   $0xe07
  8011be:	56                   	push   %esi
  8011bf:	ff 75 e4             	pushl  -0x1c(%ebp)
  8011c2:	56                   	push   %esi
  8011c3:	6a 00                	push   $0x0
  8011c5:	e8 c7 fc ff ff       	call   800e91 <sys_page_map>
  8011ca:	83 c4 20             	add    $0x20,%esp
  8011cd:	eb 30                	jmp    8011ff <fork+0x7e>
                panic("duppage: sys_page_map fail\n");
  8011cf:	83 ec 04             	sub    $0x4,%esp
  8011d2:	68 40 2b 80 00       	push   $0x802b40
  8011d7:	6a 63                	push   $0x63
  8011d9:	68 fb 2a 80 00       	push   $0x802afb
  8011de:	e8 65 f1 ff ff       	call   800348 <_panic>
            r = sys_page_map(0, addr, envid, addr, PTE_U | PTE_P);
  8011e3:	83 ec 0c             	sub    $0xc,%esp
  8011e6:	6a 05                	push   $0x5
  8011e8:	56                   	push   %esi
  8011e9:	ff 75 e4             	pushl  -0x1c(%ebp)
  8011ec:	56                   	push   %esi
  8011ed:	6a 00                	push   $0x0
  8011ef:	e8 9d fc ff ff       	call   800e91 <sys_page_map>
            if(r < 0)
  8011f4:	83 c4 20             	add    $0x20,%esp
  8011f7:	85 c0                	test   %eax,%eax
  8011f9:	0f 88 ac 00 00 00    	js     8012ab <fork+0x12a>
		for(pageVa=UTEXT;pageVa<USTACKTOP;pageVa+=PGSIZE){
  8011ff:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  801205:	81 fb 00 e0 bf ee    	cmp    $0xeebfe000,%ebx
  80120b:	0f 84 ae 00 00 00    	je     8012bf <fork+0x13e>
			pn=PGNUM(pageVa);
			//检查权限，挨个copy页
			if((uvpd[PDX(pageVa)]&PTE_P)&&(uvpt[pn]&PTE_P)&&(uvpt[pn]&PTE_U)){
  801211:	89 d8                	mov    %ebx,%eax
  801213:	c1 e8 16             	shr    $0x16,%eax
  801216:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  80121d:	a8 01                	test   $0x1,%al
  80121f:	74 de                	je     8011ff <fork+0x7e>
			pn=PGNUM(pageVa);
  801221:	89 d8                	mov    %ebx,%eax
  801223:	c1 e8 0c             	shr    $0xc,%eax
			if((uvpd[PDX(pageVa)]&PTE_P)&&(uvpt[pn]&PTE_P)&&(uvpt[pn]&PTE_U)){
  801226:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
  80122d:	f6 c2 01             	test   $0x1,%dl
  801230:	74 cd                	je     8011ff <fork+0x7e>
  801232:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
  801239:	f6 c2 04             	test   $0x4,%dl
  80123c:	74 c1                	je     8011ff <fork+0x7e>
        addr = (void *)((uint32_t)pn * PGSIZE);
  80123e:	89 c6                	mov    %eax,%esi
  801240:	c1 e6 0c             	shl    $0xc,%esi
        pte = uvpt[pn];
  801243:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
		if(pte&PTE_SHARE){
  80124a:	f6 c4 04             	test   $0x4,%ah
  80124d:	0f 85 63 ff ff ff    	jne    8011b6 <fork+0x35>
        else if((pte & PTE_COW) || (pte & PTE_W))
  801253:	a9 02 08 00 00       	test   $0x802,%eax
  801258:	74 89                	je     8011e3 <fork+0x62>
            r = sys_page_map(0, addr, envid, addr, PTE_COW | PTE_U | PTE_P);
  80125a:	83 ec 0c             	sub    $0xc,%esp
  80125d:	68 05 08 00 00       	push   $0x805
  801262:	56                   	push   %esi
  801263:	ff 75 e4             	pushl  -0x1c(%ebp)
  801266:	56                   	push   %esi
  801267:	6a 00                	push   $0x0
  801269:	e8 23 fc ff ff       	call   800e91 <sys_page_map>
            if(r < 0)
  80126e:	83 c4 20             	add    $0x20,%esp
  801271:	85 c0                	test   %eax,%eax
  801273:	0f 88 56 ff ff ff    	js     8011cf <fork+0x4e>
            r = sys_page_map(0, addr, 0, addr, PTE_COW | PTE_U | PTE_P);
  801279:	83 ec 0c             	sub    $0xc,%esp
  80127c:	68 05 08 00 00       	push   $0x805
  801281:	56                   	push   %esi
  801282:	6a 00                	push   $0x0
  801284:	56                   	push   %esi
  801285:	6a 00                	push   $0x0
  801287:	e8 05 fc ff ff       	call   800e91 <sys_page_map>
            if(r < 0)
  80128c:	83 c4 20             	add    $0x20,%esp
  80128f:	85 c0                	test   %eax,%eax
  801291:	0f 89 68 ff ff ff    	jns    8011ff <fork+0x7e>
                panic("duppage: sys_page_map fail\n");
  801297:	83 ec 04             	sub    $0x4,%esp
  80129a:	68 40 2b 80 00       	push   $0x802b40
  80129f:	6a 66                	push   $0x66
  8012a1:	68 fb 2a 80 00       	push   $0x802afb
  8012a6:	e8 9d f0 ff ff       	call   800348 <_panic>
                panic("duppage: sys_page_map fail\n");
  8012ab:	83 ec 04             	sub    $0x4,%esp
  8012ae:	68 40 2b 80 00       	push   $0x802b40
  8012b3:	6a 6c                	push   $0x6c
  8012b5:	68 fb 2a 80 00       	push   $0x802afb
  8012ba:	e8 89 f0 ff ff       	call   800348 <_panic>
				duppage(envid,pn);}
			}
		//分配异常栈。
		int32_t flag=sys_page_alloc(envid,(void*)(UXSTACKTOP-PGSIZE),PTE_P|PTE_U|PTE_W);
  8012bf:	83 ec 04             	sub    $0x4,%esp
  8012c2:	6a 07                	push   $0x7
  8012c4:	68 00 f0 bf ee       	push   $0xeebff000
  8012c9:	57                   	push   %edi
  8012ca:	e8 7b fb ff ff       	call   800e4a <sys_page_alloc>
		if(flag<0){
  8012cf:	83 c4 10             	add    $0x10,%esp
  8012d2:	85 c0                	test   %eax,%eax
  8012d4:	78 31                	js     801307 <fork+0x186>
			panic("panic by alloc page");
		}
		//设置对应的异常处理函数。
		extern void _pgfault_upcall(void);
		flag=sys_env_set_pgfault_upcall(envid,_pgfault_upcall);
  8012d6:	83 ec 08             	sub    $0x8,%esp
  8012d9:	68 ae 21 80 00       	push   $0x8021ae
  8012de:	57                   	push   %edi
  8012df:	e8 c5 fc ff ff       	call   800fa9 <sys_env_set_pgfault_upcall>
		if(flag<0){
  8012e4:	83 c4 10             	add    $0x10,%esp
  8012e7:	85 c0                	test   %eax,%eax
  8012e9:	78 33                	js     80131e <fork+0x19d>
			panic("panic by set pgfault upcall faction");
		}
		//设置子进程，等待调度。
		flag=sys_env_set_status(envid,ENV_RUNNABLE);
  8012eb:	83 ec 08             	sub    $0x8,%esp
  8012ee:	6a 02                	push   $0x2
  8012f0:	57                   	push   %edi
  8012f1:	e8 27 fc ff ff       	call   800f1d <sys_env_set_status>
		if(flag<0){
  8012f6:	83 c4 10             	add    $0x10,%esp
  8012f9:	85 c0                	test   %eax,%eax
  8012fb:	78 38                	js     801335 <fork+0x1b4>
		//否则报错。
		panic("panic by alloc envid");
	}

	
}
  8012fd:	89 f8                	mov    %edi,%eax
  8012ff:	8d 65 f4             	lea    -0xc(%ebp),%esp
  801302:	5b                   	pop    %ebx
  801303:	5e                   	pop    %esi
  801304:	5f                   	pop    %edi
  801305:	5d                   	pop    %ebp
  801306:	c3                   	ret    
			panic("panic by alloc page");
  801307:	83 ec 04             	sub    $0x4,%esp
  80130a:	68 5c 2b 80 00       	push   $0x802b5c
  80130f:	68 98 00 00 00       	push   $0x98
  801314:	68 fb 2a 80 00       	push   $0x802afb
  801319:	e8 2a f0 ff ff       	call   800348 <_panic>
			panic("panic by set pgfault upcall faction");
  80131e:	83 ec 04             	sub    $0x4,%esp
  801321:	68 b0 2a 80 00       	push   $0x802ab0
  801326:	68 9e 00 00 00       	push   $0x9e
  80132b:	68 fb 2a 80 00       	push   $0x802afb
  801330:	e8 13 f0 ff ff       	call   800348 <_panic>
			panic("panic by set env status to ENV_RUNABLE");
  801335:	83 ec 04             	sub    $0x4,%esp
  801338:	68 d4 2a 80 00       	push   $0x802ad4
  80133d:	68 a3 00 00 00       	push   $0xa3
  801342:	68 fb 2a 80 00       	push   $0x802afb
  801347:	e8 fc ef ff ff       	call   800348 <_panic>
	else if(envid==0){
  80134c:	75 19                	jne    801367 <fork+0x1e6>
        thisenv = &envs[ENVX(sys_getenvid())];	//在子进程中设置thisenv为自己
  80134e:	e8 b1 fa ff ff       	call   800e04 <sys_getenvid>
  801353:	25 ff 03 00 00       	and    $0x3ff,%eax
  801358:	6b c0 7c             	imul   $0x7c,%eax,%eax
  80135b:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  801360:	a3 04 40 80 00       	mov    %eax,0x804004
		return 0;
  801365:	eb 96                	jmp    8012fd <fork+0x17c>
		panic("panic by alloc envid");
  801367:	83 ec 04             	sub    $0x4,%esp
  80136a:	68 70 2b 80 00       	push   $0x802b70
  80136f:	68 ad 00 00 00       	push   $0xad
  801374:	68 fb 2a 80 00       	push   $0x802afb
  801379:	e8 ca ef ff ff       	call   800348 <_panic>

0080137e <sfork>:

// Challenge!
int
sfork(void)
{
  80137e:	f3 0f 1e fb          	endbr32 
  801382:	55                   	push   %ebp
  801383:	89 e5                	mov    %esp,%ebp
  801385:	83 ec 0c             	sub    $0xc,%esp
	panic("sfork not implemented");
  801388:	68 85 2b 80 00       	push   $0x802b85
  80138d:	68 b7 00 00 00       	push   $0xb7
  801392:	68 fb 2a 80 00       	push   $0x802afb
  801397:	e8 ac ef ff ff       	call   800348 <_panic>

0080139c <fd2num>:
// File descriptor manipulators
// --------------------------------------------------------------

int
fd2num(struct Fd *fd)
{
  80139c:	f3 0f 1e fb          	endbr32 
  8013a0:	55                   	push   %ebp
  8013a1:	89 e5                	mov    %esp,%ebp
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
  8013a3:	8b 45 08             	mov    0x8(%ebp),%eax
  8013a6:	05 00 00 00 30       	add    $0x30000000,%eax
  8013ab:	c1 e8 0c             	shr    $0xc,%eax
}
  8013ae:	5d                   	pop    %ebp
  8013af:	c3                   	ret    

008013b0 <fd2data>:

char*
fd2data(struct Fd *fd)
{
  8013b0:	f3 0f 1e fb          	endbr32 
  8013b4:	55                   	push   %ebp
  8013b5:	89 e5                	mov    %esp,%ebp
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
  8013b7:	8b 45 08             	mov    0x8(%ebp),%eax
  8013ba:	05 00 00 00 30       	add    $0x30000000,%eax
	return INDEX2DATA(fd2num(fd));
  8013bf:	25 00 f0 ff ff       	and    $0xfffff000,%eax
  8013c4:	2d 00 00 fe 2f       	sub    $0x2ffe0000,%eax
}
  8013c9:	5d                   	pop    %ebp
  8013ca:	c3                   	ret    

008013cb <fd_alloc>:
// Returns 0 on success, < 0 on error.  Errors are:
//	-E_MAX_FD: no more file descriptors
// On error, *fd_store is set to 0.
int
fd_alloc(struct Fd **fd_store)
{
  8013cb:	f3 0f 1e fb          	endbr32 
  8013cf:	55                   	push   %ebp
  8013d0:	89 e5                	mov    %esp,%ebp
  8013d2:	b8 00 00 00 d0       	mov    $0xd0000000,%eax
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
		fd = INDEX2FD(i);
		if ((uvpd[PDX(fd)] & PTE_P) == 0 || (uvpt[PGNUM(fd)] & PTE_P) == 0) {
  8013d7:	89 c2                	mov    %eax,%edx
  8013d9:	c1 ea 16             	shr    $0x16,%edx
  8013dc:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  8013e3:	f6 c2 01             	test   $0x1,%dl
  8013e6:	74 2d                	je     801415 <fd_alloc+0x4a>
  8013e8:	89 c2                	mov    %eax,%edx
  8013ea:	c1 ea 0c             	shr    $0xc,%edx
  8013ed:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  8013f4:	f6 c2 01             	test   $0x1,%dl
  8013f7:	74 1c                	je     801415 <fd_alloc+0x4a>
  8013f9:	05 00 10 00 00       	add    $0x1000,%eax
	for (i = 0; i < MAXFD; i++) {
  8013fe:	3d 00 00 02 d0       	cmp    $0xd0020000,%eax
  801403:	75 d2                	jne    8013d7 <fd_alloc+0xc>
			*fd_store = fd;
			return 0;
		}
	}
	*fd_store = 0;
  801405:	8b 45 08             	mov    0x8(%ebp),%eax
  801408:	c7 00 00 00 00 00    	movl   $0x0,(%eax)
	return -E_MAX_OPEN;
  80140e:	b8 f6 ff ff ff       	mov    $0xfffffff6,%eax
  801413:	eb 0a                	jmp    80141f <fd_alloc+0x54>
			*fd_store = fd;
  801415:	8b 4d 08             	mov    0x8(%ebp),%ecx
  801418:	89 01                	mov    %eax,(%ecx)
			return 0;
  80141a:	b8 00 00 00 00       	mov    $0x0,%eax
}
  80141f:	5d                   	pop    %ebp
  801420:	c3                   	ret    

00801421 <fd_lookup>:
// Returns 0 on success (the page is in range and mapped), < 0 on error.
// Errors are:
//	-E_INVAL: fdnum was either not in range or not mapped.
int
fd_lookup(int fdnum, struct Fd **fd_store)
{
  801421:	f3 0f 1e fb          	endbr32 
  801425:	55                   	push   %ebp
  801426:	89 e5                	mov    %esp,%ebp
  801428:	8b 45 08             	mov    0x8(%ebp),%eax
	struct Fd *fd;

	if (fdnum < 0 || fdnum >= MAXFD) {
  80142b:	83 f8 1f             	cmp    $0x1f,%eax
  80142e:	77 30                	ja     801460 <fd_lookup+0x3f>
		if (debug)
			cprintf("[%08x] bad fd %d\n", thisenv->env_id, fdnum);
		return -E_INVAL;
	}
	fd = INDEX2FD(fdnum);
  801430:	c1 e0 0c             	shl    $0xc,%eax
  801433:	2d 00 00 00 30       	sub    $0x30000000,%eax
	if (!(uvpd[PDX(fd)] & PTE_P) || !(uvpt[PGNUM(fd)] & PTE_P)) {
  801438:	8b 15 00 dd 7b ef    	mov    0xef7bdd00,%edx
  80143e:	f6 c2 01             	test   $0x1,%dl
  801441:	74 24                	je     801467 <fd_lookup+0x46>
  801443:	89 c2                	mov    %eax,%edx
  801445:	c1 ea 0c             	shr    $0xc,%edx
  801448:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  80144f:	f6 c2 01             	test   $0x1,%dl
  801452:	74 1a                	je     80146e <fd_lookup+0x4d>
		if (debug)
			cprintf("[%08x] closed fd %d\n", thisenv->env_id, fdnum);
		return -E_INVAL;
	}
	*fd_store = fd;
  801454:	8b 55 0c             	mov    0xc(%ebp),%edx
  801457:	89 02                	mov    %eax,(%edx)
	return 0;
  801459:	b8 00 00 00 00       	mov    $0x0,%eax
}
  80145e:	5d                   	pop    %ebp
  80145f:	c3                   	ret    
		return -E_INVAL;
  801460:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  801465:	eb f7                	jmp    80145e <fd_lookup+0x3d>
		return -E_INVAL;
  801467:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  80146c:	eb f0                	jmp    80145e <fd_lookup+0x3d>
  80146e:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  801473:	eb e9                	jmp    80145e <fd_lookup+0x3d>

00801475 <dev_lookup>:
	0
};

int
dev_lookup(int dev_id, struct Dev **dev)
{
  801475:	f3 0f 1e fb          	endbr32 
  801479:	55                   	push   %ebp
  80147a:	89 e5                	mov    %esp,%ebp
  80147c:	83 ec 08             	sub    $0x8,%esp
  80147f:	8b 4d 08             	mov    0x8(%ebp),%ecx
  801482:	ba 18 2c 80 00       	mov    $0x802c18,%edx
	int i;
	for (i = 0; devtab[i]; i++)
  801487:	b8 08 30 80 00       	mov    $0x803008,%eax
		if (devtab[i]->dev_id == dev_id) {
  80148c:	39 08                	cmp    %ecx,(%eax)
  80148e:	74 33                	je     8014c3 <dev_lookup+0x4e>
  801490:	83 c2 04             	add    $0x4,%edx
	for (i = 0; devtab[i]; i++)
  801493:	8b 02                	mov    (%edx),%eax
  801495:	85 c0                	test   %eax,%eax
  801497:	75 f3                	jne    80148c <dev_lookup+0x17>
			*dev = devtab[i];
			return 0;
		}
	cprintf("[%08x] unknown device type %d\n", thisenv->env_id, dev_id);
  801499:	a1 04 40 80 00       	mov    0x804004,%eax
  80149e:	8b 40 48             	mov    0x48(%eax),%eax
  8014a1:	83 ec 04             	sub    $0x4,%esp
  8014a4:	51                   	push   %ecx
  8014a5:	50                   	push   %eax
  8014a6:	68 9c 2b 80 00       	push   $0x802b9c
  8014ab:	e8 7f ef ff ff       	call   80042f <cprintf>
	*dev = 0;
  8014b0:	8b 45 0c             	mov    0xc(%ebp),%eax
  8014b3:	c7 00 00 00 00 00    	movl   $0x0,(%eax)
	return -E_INVAL;
  8014b9:	83 c4 10             	add    $0x10,%esp
  8014bc:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  8014c1:	c9                   	leave  
  8014c2:	c3                   	ret    
			*dev = devtab[i];
  8014c3:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8014c6:	89 01                	mov    %eax,(%ecx)
			return 0;
  8014c8:	b8 00 00 00 00       	mov    $0x0,%eax
  8014cd:	eb f2                	jmp    8014c1 <dev_lookup+0x4c>

008014cf <fd_close>:
{
  8014cf:	f3 0f 1e fb          	endbr32 
  8014d3:	55                   	push   %ebp
  8014d4:	89 e5                	mov    %esp,%ebp
  8014d6:	57                   	push   %edi
  8014d7:	56                   	push   %esi
  8014d8:	53                   	push   %ebx
  8014d9:	83 ec 24             	sub    $0x24,%esp
  8014dc:	8b 75 08             	mov    0x8(%ebp),%esi
  8014df:	8b 7d 0c             	mov    0xc(%ebp),%edi
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  8014e2:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  8014e5:	50                   	push   %eax
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
  8014e6:	8d 86 00 00 00 30    	lea    0x30000000(%esi),%eax
  8014ec:	c1 e8 0c             	shr    $0xc,%eax
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  8014ef:	50                   	push   %eax
  8014f0:	e8 2c ff ff ff       	call   801421 <fd_lookup>
  8014f5:	89 c3                	mov    %eax,%ebx
  8014f7:	83 c4 10             	add    $0x10,%esp
  8014fa:	85 c0                	test   %eax,%eax
  8014fc:	78 05                	js     801503 <fd_close+0x34>
	    || fd != fd2)
  8014fe:	39 75 e4             	cmp    %esi,-0x1c(%ebp)
  801501:	74 16                	je     801519 <fd_close+0x4a>
		return (must_exist ? r : 0);
  801503:	89 f8                	mov    %edi,%eax
  801505:	84 c0                	test   %al,%al
  801507:	b8 00 00 00 00       	mov    $0x0,%eax
  80150c:	0f 44 d8             	cmove  %eax,%ebx
}
  80150f:	89 d8                	mov    %ebx,%eax
  801511:	8d 65 f4             	lea    -0xc(%ebp),%esp
  801514:	5b                   	pop    %ebx
  801515:	5e                   	pop    %esi
  801516:	5f                   	pop    %edi
  801517:	5d                   	pop    %ebp
  801518:	c3                   	ret    
	if ((r = dev_lookup(fd->fd_dev_id, &dev)) >= 0) {
  801519:	83 ec 08             	sub    $0x8,%esp
  80151c:	8d 45 e0             	lea    -0x20(%ebp),%eax
  80151f:	50                   	push   %eax
  801520:	ff 36                	pushl  (%esi)
  801522:	e8 4e ff ff ff       	call   801475 <dev_lookup>
  801527:	89 c3                	mov    %eax,%ebx
  801529:	83 c4 10             	add    $0x10,%esp
  80152c:	85 c0                	test   %eax,%eax
  80152e:	78 1a                	js     80154a <fd_close+0x7b>
		if (dev->dev_close)
  801530:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801533:	8b 40 10             	mov    0x10(%eax),%eax
			r = 0;
  801536:	bb 00 00 00 00       	mov    $0x0,%ebx
		if (dev->dev_close)
  80153b:	85 c0                	test   %eax,%eax
  80153d:	74 0b                	je     80154a <fd_close+0x7b>
			r = (*dev->dev_close)(fd);
  80153f:	83 ec 0c             	sub    $0xc,%esp
  801542:	56                   	push   %esi
  801543:	ff d0                	call   *%eax
  801545:	89 c3                	mov    %eax,%ebx
  801547:	83 c4 10             	add    $0x10,%esp
	(void) sys_page_unmap(0, fd);
  80154a:	83 ec 08             	sub    $0x8,%esp
  80154d:	56                   	push   %esi
  80154e:	6a 00                	push   $0x0
  801550:	e8 82 f9 ff ff       	call   800ed7 <sys_page_unmap>
	return r;
  801555:	83 c4 10             	add    $0x10,%esp
  801558:	eb b5                	jmp    80150f <fd_close+0x40>

0080155a <close>:

int
close(int fdnum)
{
  80155a:	f3 0f 1e fb          	endbr32 
  80155e:	55                   	push   %ebp
  80155f:	89 e5                	mov    %esp,%ebp
  801561:	83 ec 20             	sub    $0x20,%esp
	struct Fd *fd;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  801564:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801567:	50                   	push   %eax
  801568:	ff 75 08             	pushl  0x8(%ebp)
  80156b:	e8 b1 fe ff ff       	call   801421 <fd_lookup>
  801570:	83 c4 10             	add    $0x10,%esp
  801573:	85 c0                	test   %eax,%eax
  801575:	79 02                	jns    801579 <close+0x1f>
		return r;
	else
		return fd_close(fd, 1);
}
  801577:	c9                   	leave  
  801578:	c3                   	ret    
		return fd_close(fd, 1);
  801579:	83 ec 08             	sub    $0x8,%esp
  80157c:	6a 01                	push   $0x1
  80157e:	ff 75 f4             	pushl  -0xc(%ebp)
  801581:	e8 49 ff ff ff       	call   8014cf <fd_close>
  801586:	83 c4 10             	add    $0x10,%esp
  801589:	eb ec                	jmp    801577 <close+0x1d>

0080158b <close_all>:

void
close_all(void)
{
  80158b:	f3 0f 1e fb          	endbr32 
  80158f:	55                   	push   %ebp
  801590:	89 e5                	mov    %esp,%ebp
  801592:	53                   	push   %ebx
  801593:	83 ec 04             	sub    $0x4,%esp
	int i;
	for (i = 0; i < MAXFD; i++)
  801596:	bb 00 00 00 00       	mov    $0x0,%ebx
		close(i);
  80159b:	83 ec 0c             	sub    $0xc,%esp
  80159e:	53                   	push   %ebx
  80159f:	e8 b6 ff ff ff       	call   80155a <close>
	for (i = 0; i < MAXFD; i++)
  8015a4:	83 c3 01             	add    $0x1,%ebx
  8015a7:	83 c4 10             	add    $0x10,%esp
  8015aa:	83 fb 20             	cmp    $0x20,%ebx
  8015ad:	75 ec                	jne    80159b <close_all+0x10>
}
  8015af:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  8015b2:	c9                   	leave  
  8015b3:	c3                   	ret    

008015b4 <dup>:
// file and the file offset of the other.
// Closes any previously open file descriptor at 'newfdnum'.
// This is implemented using virtual memory tricks (of course!).
int
dup(int oldfdnum, int newfdnum)
{
  8015b4:	f3 0f 1e fb          	endbr32 
  8015b8:	55                   	push   %ebp
  8015b9:	89 e5                	mov    %esp,%ebp
  8015bb:	57                   	push   %edi
  8015bc:	56                   	push   %esi
  8015bd:	53                   	push   %ebx
  8015be:	83 ec 24             	sub    $0x24,%esp
	int r;
	char *ova, *nva;
	pte_t pte;
	struct Fd *oldfd, *newfd;

	if ((r = fd_lookup(oldfdnum, &oldfd)) < 0)
  8015c1:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  8015c4:	50                   	push   %eax
  8015c5:	ff 75 08             	pushl  0x8(%ebp)
  8015c8:	e8 54 fe ff ff       	call   801421 <fd_lookup>
  8015cd:	89 c3                	mov    %eax,%ebx
  8015cf:	83 c4 10             	add    $0x10,%esp
  8015d2:	85 c0                	test   %eax,%eax
  8015d4:	0f 88 81 00 00 00    	js     80165b <dup+0xa7>
		return r;
	close(newfdnum);
  8015da:	83 ec 0c             	sub    $0xc,%esp
  8015dd:	ff 75 0c             	pushl  0xc(%ebp)
  8015e0:	e8 75 ff ff ff       	call   80155a <close>

	newfd = INDEX2FD(newfdnum);
  8015e5:	8b 75 0c             	mov    0xc(%ebp),%esi
  8015e8:	c1 e6 0c             	shl    $0xc,%esi
  8015eb:	81 ee 00 00 00 30    	sub    $0x30000000,%esi
	ova = fd2data(oldfd);
  8015f1:	83 c4 04             	add    $0x4,%esp
  8015f4:	ff 75 e4             	pushl  -0x1c(%ebp)
  8015f7:	e8 b4 fd ff ff       	call   8013b0 <fd2data>
  8015fc:	89 c3                	mov    %eax,%ebx
	nva = fd2data(newfd);
  8015fe:	89 34 24             	mov    %esi,(%esp)
  801601:	e8 aa fd ff ff       	call   8013b0 <fd2data>
  801606:	83 c4 10             	add    $0x10,%esp
  801609:	89 c7                	mov    %eax,%edi

	if ((uvpd[PDX(ova)] & PTE_P) && (uvpt[PGNUM(ova)] & PTE_P))
  80160b:	89 d8                	mov    %ebx,%eax
  80160d:	c1 e8 16             	shr    $0x16,%eax
  801610:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  801617:	a8 01                	test   $0x1,%al
  801619:	74 11                	je     80162c <dup+0x78>
  80161b:	89 d8                	mov    %ebx,%eax
  80161d:	c1 e8 0c             	shr    $0xc,%eax
  801620:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
  801627:	f6 c2 01             	test   $0x1,%dl
  80162a:	75 39                	jne    801665 <dup+0xb1>
		if ((r = sys_page_map(0, ova, 0, nva, uvpt[PGNUM(ova)] & PTE_SYSCALL)) < 0)
			goto err;
	if ((r = sys_page_map(0, oldfd, 0, newfd, uvpt[PGNUM(oldfd)] & PTE_SYSCALL)) < 0)
  80162c:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  80162f:	89 d0                	mov    %edx,%eax
  801631:	c1 e8 0c             	shr    $0xc,%eax
  801634:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  80163b:	83 ec 0c             	sub    $0xc,%esp
  80163e:	25 07 0e 00 00       	and    $0xe07,%eax
  801643:	50                   	push   %eax
  801644:	56                   	push   %esi
  801645:	6a 00                	push   $0x0
  801647:	52                   	push   %edx
  801648:	6a 00                	push   $0x0
  80164a:	e8 42 f8 ff ff       	call   800e91 <sys_page_map>
  80164f:	89 c3                	mov    %eax,%ebx
  801651:	83 c4 20             	add    $0x20,%esp
  801654:	85 c0                	test   %eax,%eax
  801656:	78 31                	js     801689 <dup+0xd5>
		goto err;

	return newfdnum;
  801658:	8b 5d 0c             	mov    0xc(%ebp),%ebx

err:
	sys_page_unmap(0, newfd);
	sys_page_unmap(0, nva);
	return r;
}
  80165b:	89 d8                	mov    %ebx,%eax
  80165d:	8d 65 f4             	lea    -0xc(%ebp),%esp
  801660:	5b                   	pop    %ebx
  801661:	5e                   	pop    %esi
  801662:	5f                   	pop    %edi
  801663:	5d                   	pop    %ebp
  801664:	c3                   	ret    
		if ((r = sys_page_map(0, ova, 0, nva, uvpt[PGNUM(ova)] & PTE_SYSCALL)) < 0)
  801665:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  80166c:	83 ec 0c             	sub    $0xc,%esp
  80166f:	25 07 0e 00 00       	and    $0xe07,%eax
  801674:	50                   	push   %eax
  801675:	57                   	push   %edi
  801676:	6a 00                	push   $0x0
  801678:	53                   	push   %ebx
  801679:	6a 00                	push   $0x0
  80167b:	e8 11 f8 ff ff       	call   800e91 <sys_page_map>
  801680:	89 c3                	mov    %eax,%ebx
  801682:	83 c4 20             	add    $0x20,%esp
  801685:	85 c0                	test   %eax,%eax
  801687:	79 a3                	jns    80162c <dup+0x78>
	sys_page_unmap(0, newfd);
  801689:	83 ec 08             	sub    $0x8,%esp
  80168c:	56                   	push   %esi
  80168d:	6a 00                	push   $0x0
  80168f:	e8 43 f8 ff ff       	call   800ed7 <sys_page_unmap>
	sys_page_unmap(0, nva);
  801694:	83 c4 08             	add    $0x8,%esp
  801697:	57                   	push   %edi
  801698:	6a 00                	push   $0x0
  80169a:	e8 38 f8 ff ff       	call   800ed7 <sys_page_unmap>
	return r;
  80169f:	83 c4 10             	add    $0x10,%esp
  8016a2:	eb b7                	jmp    80165b <dup+0xa7>

008016a4 <read>:

ssize_t
read(int fdnum, void *buf, size_t n)
{
  8016a4:	f3 0f 1e fb          	endbr32 
  8016a8:	55                   	push   %ebp
  8016a9:	89 e5                	mov    %esp,%ebp
  8016ab:	53                   	push   %ebx
  8016ac:	83 ec 1c             	sub    $0x1c,%esp
  8016af:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8016b2:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8016b5:	50                   	push   %eax
  8016b6:	53                   	push   %ebx
  8016b7:	e8 65 fd ff ff       	call   801421 <fd_lookup>
  8016bc:	83 c4 10             	add    $0x10,%esp
  8016bf:	85 c0                	test   %eax,%eax
  8016c1:	78 3f                	js     801702 <read+0x5e>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  8016c3:	83 ec 08             	sub    $0x8,%esp
  8016c6:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8016c9:	50                   	push   %eax
  8016ca:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8016cd:	ff 30                	pushl  (%eax)
  8016cf:	e8 a1 fd ff ff       	call   801475 <dev_lookup>
  8016d4:	83 c4 10             	add    $0x10,%esp
  8016d7:	85 c0                	test   %eax,%eax
  8016d9:	78 27                	js     801702 <read+0x5e>
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_WRONLY) {
  8016db:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8016de:	8b 42 08             	mov    0x8(%edx),%eax
  8016e1:	83 e0 03             	and    $0x3,%eax
  8016e4:	83 f8 01             	cmp    $0x1,%eax
  8016e7:	74 1e                	je     801707 <read+0x63>
		cprintf("[%08x] read %d -- bad mode\n", thisenv->env_id, fdnum);
		return -E_INVAL;
	}
	if (!dev->dev_read)
  8016e9:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8016ec:	8b 40 08             	mov    0x8(%eax),%eax
  8016ef:	85 c0                	test   %eax,%eax
  8016f1:	74 35                	je     801728 <read+0x84>
		return -E_NOT_SUPP;
	return (*dev->dev_read)(fd, buf, n);
  8016f3:	83 ec 04             	sub    $0x4,%esp
  8016f6:	ff 75 10             	pushl  0x10(%ebp)
  8016f9:	ff 75 0c             	pushl  0xc(%ebp)
  8016fc:	52                   	push   %edx
  8016fd:	ff d0                	call   *%eax
  8016ff:	83 c4 10             	add    $0x10,%esp
}
  801702:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  801705:	c9                   	leave  
  801706:	c3                   	ret    
		cprintf("[%08x] read %d -- bad mode\n", thisenv->env_id, fdnum);
  801707:	a1 04 40 80 00       	mov    0x804004,%eax
  80170c:	8b 40 48             	mov    0x48(%eax),%eax
  80170f:	83 ec 04             	sub    $0x4,%esp
  801712:	53                   	push   %ebx
  801713:	50                   	push   %eax
  801714:	68 dd 2b 80 00       	push   $0x802bdd
  801719:	e8 11 ed ff ff       	call   80042f <cprintf>
		return -E_INVAL;
  80171e:	83 c4 10             	add    $0x10,%esp
  801721:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  801726:	eb da                	jmp    801702 <read+0x5e>
		return -E_NOT_SUPP;
  801728:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  80172d:	eb d3                	jmp    801702 <read+0x5e>

0080172f <readn>:

ssize_t
readn(int fdnum, void *buf, size_t n)
{
  80172f:	f3 0f 1e fb          	endbr32 
  801733:	55                   	push   %ebp
  801734:	89 e5                	mov    %esp,%ebp
  801736:	57                   	push   %edi
  801737:	56                   	push   %esi
  801738:	53                   	push   %ebx
  801739:	83 ec 0c             	sub    $0xc,%esp
  80173c:	8b 7d 08             	mov    0x8(%ebp),%edi
  80173f:	8b 75 10             	mov    0x10(%ebp),%esi
	int m, tot;

	for (tot = 0; tot < n; tot += m) {
  801742:	bb 00 00 00 00       	mov    $0x0,%ebx
  801747:	eb 02                	jmp    80174b <readn+0x1c>
  801749:	01 c3                	add    %eax,%ebx
  80174b:	39 f3                	cmp    %esi,%ebx
  80174d:	73 21                	jae    801770 <readn+0x41>
		m = read(fdnum, (char*)buf + tot, n - tot);
  80174f:	83 ec 04             	sub    $0x4,%esp
  801752:	89 f0                	mov    %esi,%eax
  801754:	29 d8                	sub    %ebx,%eax
  801756:	50                   	push   %eax
  801757:	89 d8                	mov    %ebx,%eax
  801759:	03 45 0c             	add    0xc(%ebp),%eax
  80175c:	50                   	push   %eax
  80175d:	57                   	push   %edi
  80175e:	e8 41 ff ff ff       	call   8016a4 <read>
		if (m < 0)
  801763:	83 c4 10             	add    $0x10,%esp
  801766:	85 c0                	test   %eax,%eax
  801768:	78 04                	js     80176e <readn+0x3f>
			return m;
		if (m == 0)
  80176a:	75 dd                	jne    801749 <readn+0x1a>
  80176c:	eb 02                	jmp    801770 <readn+0x41>
		m = read(fdnum, (char*)buf + tot, n - tot);
  80176e:	89 c3                	mov    %eax,%ebx
			break;
	}
	return tot;
}
  801770:	89 d8                	mov    %ebx,%eax
  801772:	8d 65 f4             	lea    -0xc(%ebp),%esp
  801775:	5b                   	pop    %ebx
  801776:	5e                   	pop    %esi
  801777:	5f                   	pop    %edi
  801778:	5d                   	pop    %ebp
  801779:	c3                   	ret    

0080177a <write>:

ssize_t
write(int fdnum, const void *buf, size_t n)
{
  80177a:	f3 0f 1e fb          	endbr32 
  80177e:	55                   	push   %ebp
  80177f:	89 e5                	mov    %esp,%ebp
  801781:	53                   	push   %ebx
  801782:	83 ec 1c             	sub    $0x1c,%esp
  801785:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801788:	8d 45 f0             	lea    -0x10(%ebp),%eax
  80178b:	50                   	push   %eax
  80178c:	53                   	push   %ebx
  80178d:	e8 8f fc ff ff       	call   801421 <fd_lookup>
  801792:	83 c4 10             	add    $0x10,%esp
  801795:	85 c0                	test   %eax,%eax
  801797:	78 3a                	js     8017d3 <write+0x59>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801799:	83 ec 08             	sub    $0x8,%esp
  80179c:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80179f:	50                   	push   %eax
  8017a0:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8017a3:	ff 30                	pushl  (%eax)
  8017a5:	e8 cb fc ff ff       	call   801475 <dev_lookup>
  8017aa:	83 c4 10             	add    $0x10,%esp
  8017ad:	85 c0                	test   %eax,%eax
  8017af:	78 22                	js     8017d3 <write+0x59>
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  8017b1:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8017b4:	f6 40 08 03          	testb  $0x3,0x8(%eax)
  8017b8:	74 1e                	je     8017d8 <write+0x5e>
		return -E_INVAL;
	}
	if (debug)
		cprintf("write %d %p %d via dev %s\n",
			fdnum, buf, n, dev->dev_name);
	if (!dev->dev_write)
  8017ba:	8b 55 f4             	mov    -0xc(%ebp),%edx
  8017bd:	8b 52 0c             	mov    0xc(%edx),%edx
  8017c0:	85 d2                	test   %edx,%edx
  8017c2:	74 35                	je     8017f9 <write+0x7f>
		return -E_NOT_SUPP;
	return (*dev->dev_write)(fd, buf, n);
  8017c4:	83 ec 04             	sub    $0x4,%esp
  8017c7:	ff 75 10             	pushl  0x10(%ebp)
  8017ca:	ff 75 0c             	pushl  0xc(%ebp)
  8017cd:	50                   	push   %eax
  8017ce:	ff d2                	call   *%edx
  8017d0:	83 c4 10             	add    $0x10,%esp
}
  8017d3:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  8017d6:	c9                   	leave  
  8017d7:	c3                   	ret    
		cprintf("[%08x] write %d -- bad mode\n", thisenv->env_id, fdnum);
  8017d8:	a1 04 40 80 00       	mov    0x804004,%eax
  8017dd:	8b 40 48             	mov    0x48(%eax),%eax
  8017e0:	83 ec 04             	sub    $0x4,%esp
  8017e3:	53                   	push   %ebx
  8017e4:	50                   	push   %eax
  8017e5:	68 f9 2b 80 00       	push   $0x802bf9
  8017ea:	e8 40 ec ff ff       	call   80042f <cprintf>
		return -E_INVAL;
  8017ef:	83 c4 10             	add    $0x10,%esp
  8017f2:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  8017f7:	eb da                	jmp    8017d3 <write+0x59>
		return -E_NOT_SUPP;
  8017f9:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8017fe:	eb d3                	jmp    8017d3 <write+0x59>

00801800 <seek>:

int
seek(int fdnum, off_t offset)
{
  801800:	f3 0f 1e fb          	endbr32 
  801804:	55                   	push   %ebp
  801805:	89 e5                	mov    %esp,%ebp
  801807:	83 ec 20             	sub    $0x20,%esp
	int r;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  80180a:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80180d:	50                   	push   %eax
  80180e:	ff 75 08             	pushl  0x8(%ebp)
  801811:	e8 0b fc ff ff       	call   801421 <fd_lookup>
  801816:	83 c4 10             	add    $0x10,%esp
  801819:	85 c0                	test   %eax,%eax
  80181b:	78 0e                	js     80182b <seek+0x2b>
		return r;
	fd->fd_offset = offset;
  80181d:	8b 55 0c             	mov    0xc(%ebp),%edx
  801820:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801823:	89 50 04             	mov    %edx,0x4(%eax)
	return 0;
  801826:	b8 00 00 00 00       	mov    $0x0,%eax
}
  80182b:	c9                   	leave  
  80182c:	c3                   	ret    

0080182d <ftruncate>:

int
ftruncate(int fdnum, off_t newsize)
{
  80182d:	f3 0f 1e fb          	endbr32 
  801831:	55                   	push   %ebp
  801832:	89 e5                	mov    %esp,%ebp
  801834:	53                   	push   %ebx
  801835:	83 ec 1c             	sub    $0x1c,%esp
  801838:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  80183b:	8d 45 f0             	lea    -0x10(%ebp),%eax
  80183e:	50                   	push   %eax
  80183f:	53                   	push   %ebx
  801840:	e8 dc fb ff ff       	call   801421 <fd_lookup>
  801845:	83 c4 10             	add    $0x10,%esp
  801848:	85 c0                	test   %eax,%eax
  80184a:	78 37                	js     801883 <ftruncate+0x56>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  80184c:	83 ec 08             	sub    $0x8,%esp
  80184f:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801852:	50                   	push   %eax
  801853:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801856:	ff 30                	pushl  (%eax)
  801858:	e8 18 fc ff ff       	call   801475 <dev_lookup>
  80185d:	83 c4 10             	add    $0x10,%esp
  801860:	85 c0                	test   %eax,%eax
  801862:	78 1f                	js     801883 <ftruncate+0x56>
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  801864:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801867:	f6 40 08 03          	testb  $0x3,0x8(%eax)
  80186b:	74 1b                	je     801888 <ftruncate+0x5b>
		cprintf("[%08x] ftruncate %d -- bad mode\n",
			thisenv->env_id, fdnum);
		return -E_INVAL;
	}
	if (!dev->dev_trunc)
  80186d:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801870:	8b 52 18             	mov    0x18(%edx),%edx
  801873:	85 d2                	test   %edx,%edx
  801875:	74 32                	je     8018a9 <ftruncate+0x7c>
		return -E_NOT_SUPP;
	return (*dev->dev_trunc)(fd, newsize);
  801877:	83 ec 08             	sub    $0x8,%esp
  80187a:	ff 75 0c             	pushl  0xc(%ebp)
  80187d:	50                   	push   %eax
  80187e:	ff d2                	call   *%edx
  801880:	83 c4 10             	add    $0x10,%esp
}
  801883:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  801886:	c9                   	leave  
  801887:	c3                   	ret    
			thisenv->env_id, fdnum);
  801888:	a1 04 40 80 00       	mov    0x804004,%eax
		cprintf("[%08x] ftruncate %d -- bad mode\n",
  80188d:	8b 40 48             	mov    0x48(%eax),%eax
  801890:	83 ec 04             	sub    $0x4,%esp
  801893:	53                   	push   %ebx
  801894:	50                   	push   %eax
  801895:	68 bc 2b 80 00       	push   $0x802bbc
  80189a:	e8 90 eb ff ff       	call   80042f <cprintf>
		return -E_INVAL;
  80189f:	83 c4 10             	add    $0x10,%esp
  8018a2:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  8018a7:	eb da                	jmp    801883 <ftruncate+0x56>
		return -E_NOT_SUPP;
  8018a9:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8018ae:	eb d3                	jmp    801883 <ftruncate+0x56>

008018b0 <fstat>:

int
fstat(int fdnum, struct Stat *stat)
{
  8018b0:	f3 0f 1e fb          	endbr32 
  8018b4:	55                   	push   %ebp
  8018b5:	89 e5                	mov    %esp,%ebp
  8018b7:	53                   	push   %ebx
  8018b8:	83 ec 1c             	sub    $0x1c,%esp
  8018bb:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8018be:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8018c1:	50                   	push   %eax
  8018c2:	ff 75 08             	pushl  0x8(%ebp)
  8018c5:	e8 57 fb ff ff       	call   801421 <fd_lookup>
  8018ca:	83 c4 10             	add    $0x10,%esp
  8018cd:	85 c0                	test   %eax,%eax
  8018cf:	78 4b                	js     80191c <fstat+0x6c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  8018d1:	83 ec 08             	sub    $0x8,%esp
  8018d4:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8018d7:	50                   	push   %eax
  8018d8:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8018db:	ff 30                	pushl  (%eax)
  8018dd:	e8 93 fb ff ff       	call   801475 <dev_lookup>
  8018e2:	83 c4 10             	add    $0x10,%esp
  8018e5:	85 c0                	test   %eax,%eax
  8018e7:	78 33                	js     80191c <fstat+0x6c>
		return r;
	if (!dev->dev_stat)
  8018e9:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8018ec:	83 78 14 00          	cmpl   $0x0,0x14(%eax)
  8018f0:	74 2f                	je     801921 <fstat+0x71>
		return -E_NOT_SUPP;
	stat->st_name[0] = 0;
  8018f2:	c6 03 00             	movb   $0x0,(%ebx)
	stat->st_size = 0;
  8018f5:	c7 83 80 00 00 00 00 	movl   $0x0,0x80(%ebx)
  8018fc:	00 00 00 
	stat->st_isdir = 0;
  8018ff:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  801906:	00 00 00 
	stat->st_dev = dev;
  801909:	89 83 88 00 00 00    	mov    %eax,0x88(%ebx)
	return (*dev->dev_stat)(fd, stat);
  80190f:	83 ec 08             	sub    $0x8,%esp
  801912:	53                   	push   %ebx
  801913:	ff 75 f0             	pushl  -0x10(%ebp)
  801916:	ff 50 14             	call   *0x14(%eax)
  801919:	83 c4 10             	add    $0x10,%esp
}
  80191c:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  80191f:	c9                   	leave  
  801920:	c3                   	ret    
		return -E_NOT_SUPP;
  801921:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801926:	eb f4                	jmp    80191c <fstat+0x6c>

00801928 <stat>:

int
stat(const char *path, struct Stat *stat)
{
  801928:	f3 0f 1e fb          	endbr32 
  80192c:	55                   	push   %ebp
  80192d:	89 e5                	mov    %esp,%ebp
  80192f:	56                   	push   %esi
  801930:	53                   	push   %ebx
	int fd, r;

	if ((fd = open(path, O_RDONLY)) < 0)
  801931:	83 ec 08             	sub    $0x8,%esp
  801934:	6a 00                	push   $0x0
  801936:	ff 75 08             	pushl  0x8(%ebp)
  801939:	e8 fb 01 00 00       	call   801b39 <open>
  80193e:	89 c3                	mov    %eax,%ebx
  801940:	83 c4 10             	add    $0x10,%esp
  801943:	85 c0                	test   %eax,%eax
  801945:	78 1b                	js     801962 <stat+0x3a>
		return fd;
	r = fstat(fd, stat);
  801947:	83 ec 08             	sub    $0x8,%esp
  80194a:	ff 75 0c             	pushl  0xc(%ebp)
  80194d:	50                   	push   %eax
  80194e:	e8 5d ff ff ff       	call   8018b0 <fstat>
  801953:	89 c6                	mov    %eax,%esi
	close(fd);
  801955:	89 1c 24             	mov    %ebx,(%esp)
  801958:	e8 fd fb ff ff       	call   80155a <close>
	return r;
  80195d:	83 c4 10             	add    $0x10,%esp
  801960:	89 f3                	mov    %esi,%ebx
}
  801962:	89 d8                	mov    %ebx,%eax
  801964:	8d 65 f8             	lea    -0x8(%ebp),%esp
  801967:	5b                   	pop    %ebx
  801968:	5e                   	pop    %esi
  801969:	5d                   	pop    %ebp
  80196a:	c3                   	ret    

0080196b <fsipc>:
// type: request code, passed as the simple integer IPC value.
// dstva: virtual address at which to receive reply page, 0 if none.
// Returns result from the file server.
static int
fsipc(unsigned type, void *dstva)
{
  80196b:	55                   	push   %ebp
  80196c:	89 e5                	mov    %esp,%ebp
  80196e:	56                   	push   %esi
  80196f:	53                   	push   %ebx
  801970:	89 c6                	mov    %eax,%esi
  801972:	89 d3                	mov    %edx,%ebx
	static envid_t fsenv;
	if (fsenv == 0)
  801974:	83 3d 00 40 80 00 00 	cmpl   $0x0,0x804000
  80197b:	74 27                	je     8019a4 <fsipc+0x39>
	static_assert(sizeof(fsipcbuf) == PGSIZE);

	if (debug)
		cprintf("[%08x] fsipc %d %08x\n", thisenv->env_id, type, *(uint32_t *)&fsipcbuf);

	ipc_send(fsenv, type, &fsipcbuf, PTE_P | PTE_W | PTE_U);
  80197d:	6a 07                	push   $0x7
  80197f:	68 00 50 80 00       	push   $0x805000
  801984:	56                   	push   %esi
  801985:	ff 35 00 40 80 00    	pushl  0x804000
  80198b:	e8 c6 08 00 00       	call   802256 <ipc_send>
	return ipc_recv(NULL, dstva, NULL);
  801990:	83 c4 0c             	add    $0xc,%esp
  801993:	6a 00                	push   $0x0
  801995:	53                   	push   %ebx
  801996:	6a 00                	push   $0x0
  801998:	e8 38 08 00 00       	call   8021d5 <ipc_recv>
}
  80199d:	8d 65 f8             	lea    -0x8(%ebp),%esp
  8019a0:	5b                   	pop    %ebx
  8019a1:	5e                   	pop    %esi
  8019a2:	5d                   	pop    %ebp
  8019a3:	c3                   	ret    
		fsenv = ipc_find_env(ENV_TYPE_FS);
  8019a4:	83 ec 0c             	sub    $0xc,%esp
  8019a7:	6a 01                	push   $0x1
  8019a9:	e8 00 09 00 00       	call   8022ae <ipc_find_env>
  8019ae:	a3 00 40 80 00       	mov    %eax,0x804000
  8019b3:	83 c4 10             	add    $0x10,%esp
  8019b6:	eb c5                	jmp    80197d <fsipc+0x12>

008019b8 <devfile_trunc>:
}

// Truncate or extend an open file to 'size' bytes
static int
devfile_trunc(struct Fd *fd, off_t newsize)
{
  8019b8:	f3 0f 1e fb          	endbr32 
  8019bc:	55                   	push   %ebp
  8019bd:	89 e5                	mov    %esp,%ebp
  8019bf:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.set_size.req_fileid = fd->fd_file.id;
  8019c2:	8b 45 08             	mov    0x8(%ebp),%eax
  8019c5:	8b 40 0c             	mov    0xc(%eax),%eax
  8019c8:	a3 00 50 80 00       	mov    %eax,0x805000
	fsipcbuf.set_size.req_size = newsize;
  8019cd:	8b 45 0c             	mov    0xc(%ebp),%eax
  8019d0:	a3 04 50 80 00       	mov    %eax,0x805004
	return fsipc(FSREQ_SET_SIZE, NULL);
  8019d5:	ba 00 00 00 00       	mov    $0x0,%edx
  8019da:	b8 02 00 00 00       	mov    $0x2,%eax
  8019df:	e8 87 ff ff ff       	call   80196b <fsipc>
}
  8019e4:	c9                   	leave  
  8019e5:	c3                   	ret    

008019e6 <devfile_flush>:
{
  8019e6:	f3 0f 1e fb          	endbr32 
  8019ea:	55                   	push   %ebp
  8019eb:	89 e5                	mov    %esp,%ebp
  8019ed:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.flush.req_fileid = fd->fd_file.id;
  8019f0:	8b 45 08             	mov    0x8(%ebp),%eax
  8019f3:	8b 40 0c             	mov    0xc(%eax),%eax
  8019f6:	a3 00 50 80 00       	mov    %eax,0x805000
	return fsipc(FSREQ_FLUSH, NULL);
  8019fb:	ba 00 00 00 00       	mov    $0x0,%edx
  801a00:	b8 06 00 00 00       	mov    $0x6,%eax
  801a05:	e8 61 ff ff ff       	call   80196b <fsipc>
}
  801a0a:	c9                   	leave  
  801a0b:	c3                   	ret    

00801a0c <devfile_stat>:
{
  801a0c:	f3 0f 1e fb          	endbr32 
  801a10:	55                   	push   %ebp
  801a11:	89 e5                	mov    %esp,%ebp
  801a13:	53                   	push   %ebx
  801a14:	83 ec 04             	sub    $0x4,%esp
  801a17:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	fsipcbuf.stat.req_fileid = fd->fd_file.id;
  801a1a:	8b 45 08             	mov    0x8(%ebp),%eax
  801a1d:	8b 40 0c             	mov    0xc(%eax),%eax
  801a20:	a3 00 50 80 00       	mov    %eax,0x805000
	if ((r = fsipc(FSREQ_STAT, NULL)) < 0)
  801a25:	ba 00 00 00 00       	mov    $0x0,%edx
  801a2a:	b8 05 00 00 00       	mov    $0x5,%eax
  801a2f:	e8 37 ff ff ff       	call   80196b <fsipc>
  801a34:	85 c0                	test   %eax,%eax
  801a36:	78 2c                	js     801a64 <devfile_stat+0x58>
	strcpy(st->st_name, fsipcbuf.statRet.ret_name);
  801a38:	83 ec 08             	sub    $0x8,%esp
  801a3b:	68 00 50 80 00       	push   $0x805000
  801a40:	53                   	push   %ebx
  801a41:	e8 c2 ef ff ff       	call   800a08 <strcpy>
	st->st_size = fsipcbuf.statRet.ret_size;
  801a46:	a1 80 50 80 00       	mov    0x805080,%eax
  801a4b:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	st->st_isdir = fsipcbuf.statRet.ret_isdir;
  801a51:	a1 84 50 80 00       	mov    0x805084,%eax
  801a56:	89 83 84 00 00 00    	mov    %eax,0x84(%ebx)
	return 0;
  801a5c:	83 c4 10             	add    $0x10,%esp
  801a5f:	b8 00 00 00 00       	mov    $0x0,%eax
}
  801a64:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  801a67:	c9                   	leave  
  801a68:	c3                   	ret    

00801a69 <devfile_write>:
{
  801a69:	f3 0f 1e fb          	endbr32 
  801a6d:	55                   	push   %ebp
  801a6e:	89 e5                	mov    %esp,%ebp
  801a70:	83 ec 0c             	sub    $0xc,%esp
  801a73:	8b 45 10             	mov    0x10(%ebp),%eax
  801a76:	3d f8 0f 00 00       	cmp    $0xff8,%eax
  801a7b:	ba f8 0f 00 00       	mov    $0xff8,%edx
  801a80:	0f 47 c2             	cmova  %edx,%eax
	fsipcbuf.write.req_fileid = fd->fd_file.id;
  801a83:	8b 55 08             	mov    0x8(%ebp),%edx
  801a86:	8b 52 0c             	mov    0xc(%edx),%edx
  801a89:	89 15 00 50 80 00    	mov    %edx,0x805000
	fsipcbuf.write.req_n = n;
  801a8f:	a3 04 50 80 00       	mov    %eax,0x805004
	memmove(fsipcbuf.write.req_buf, buf, n);
  801a94:	50                   	push   %eax
  801a95:	ff 75 0c             	pushl  0xc(%ebp)
  801a98:	68 08 50 80 00       	push   $0x805008
  801a9d:	e8 1c f1 ff ff       	call   800bbe <memmove>
	return fsipc(FSREQ_WRITE, NULL);}
  801aa2:	ba 00 00 00 00       	mov    $0x0,%edx
  801aa7:	b8 04 00 00 00       	mov    $0x4,%eax
  801aac:	e8 ba fe ff ff       	call   80196b <fsipc>
  801ab1:	c9                   	leave  
  801ab2:	c3                   	ret    

00801ab3 <devfile_read>:
{
  801ab3:	f3 0f 1e fb          	endbr32 
  801ab7:	55                   	push   %ebp
  801ab8:	89 e5                	mov    %esp,%ebp
  801aba:	56                   	push   %esi
  801abb:	53                   	push   %ebx
  801abc:	8b 75 10             	mov    0x10(%ebp),%esi
	fsipcbuf.read.req_fileid = fd->fd_file.id;
  801abf:	8b 45 08             	mov    0x8(%ebp),%eax
  801ac2:	8b 40 0c             	mov    0xc(%eax),%eax
  801ac5:	a3 00 50 80 00       	mov    %eax,0x805000
	fsipcbuf.read.req_n = n;
  801aca:	89 35 04 50 80 00    	mov    %esi,0x805004
	if ((r = fsipc(FSREQ_READ, NULL)) < 0)
  801ad0:	ba 00 00 00 00       	mov    $0x0,%edx
  801ad5:	b8 03 00 00 00       	mov    $0x3,%eax
  801ada:	e8 8c fe ff ff       	call   80196b <fsipc>
  801adf:	89 c3                	mov    %eax,%ebx
  801ae1:	85 c0                	test   %eax,%eax
  801ae3:	78 1f                	js     801b04 <devfile_read+0x51>
	assert(r <= n);
  801ae5:	39 f0                	cmp    %esi,%eax
  801ae7:	77 24                	ja     801b0d <devfile_read+0x5a>
	assert(r <= PGSIZE);
  801ae9:	3d 00 10 00 00       	cmp    $0x1000,%eax
  801aee:	7f 33                	jg     801b23 <devfile_read+0x70>
	memmove(buf, fsipcbuf.readRet.ret_buf, r);
  801af0:	83 ec 04             	sub    $0x4,%esp
  801af3:	50                   	push   %eax
  801af4:	68 00 50 80 00       	push   $0x805000
  801af9:	ff 75 0c             	pushl  0xc(%ebp)
  801afc:	e8 bd f0 ff ff       	call   800bbe <memmove>
	return r;
  801b01:	83 c4 10             	add    $0x10,%esp
}
  801b04:	89 d8                	mov    %ebx,%eax
  801b06:	8d 65 f8             	lea    -0x8(%ebp),%esp
  801b09:	5b                   	pop    %ebx
  801b0a:	5e                   	pop    %esi
  801b0b:	5d                   	pop    %ebp
  801b0c:	c3                   	ret    
	assert(r <= n);
  801b0d:	68 28 2c 80 00       	push   $0x802c28
  801b12:	68 2f 2c 80 00       	push   $0x802c2f
  801b17:	6a 7c                	push   $0x7c
  801b19:	68 44 2c 80 00       	push   $0x802c44
  801b1e:	e8 25 e8 ff ff       	call   800348 <_panic>
	assert(r <= PGSIZE);
  801b23:	68 4f 2c 80 00       	push   $0x802c4f
  801b28:	68 2f 2c 80 00       	push   $0x802c2f
  801b2d:	6a 7d                	push   $0x7d
  801b2f:	68 44 2c 80 00       	push   $0x802c44
  801b34:	e8 0f e8 ff ff       	call   800348 <_panic>

00801b39 <open>:
{
  801b39:	f3 0f 1e fb          	endbr32 
  801b3d:	55                   	push   %ebp
  801b3e:	89 e5                	mov    %esp,%ebp
  801b40:	56                   	push   %esi
  801b41:	53                   	push   %ebx
  801b42:	83 ec 1c             	sub    $0x1c,%esp
  801b45:	8b 75 08             	mov    0x8(%ebp),%esi
	if (strlen(path) >= MAXPATHLEN)
  801b48:	56                   	push   %esi
  801b49:	e8 77 ee ff ff       	call   8009c5 <strlen>
  801b4e:	83 c4 10             	add    $0x10,%esp
  801b51:	3d ff 03 00 00       	cmp    $0x3ff,%eax
  801b56:	7f 6c                	jg     801bc4 <open+0x8b>
	if ((r = fd_alloc(&fd)) < 0)
  801b58:	83 ec 0c             	sub    $0xc,%esp
  801b5b:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801b5e:	50                   	push   %eax
  801b5f:	e8 67 f8 ff ff       	call   8013cb <fd_alloc>
  801b64:	89 c3                	mov    %eax,%ebx
  801b66:	83 c4 10             	add    $0x10,%esp
  801b69:	85 c0                	test   %eax,%eax
  801b6b:	78 3c                	js     801ba9 <open+0x70>
	strcpy(fsipcbuf.open.req_path, path);
  801b6d:	83 ec 08             	sub    $0x8,%esp
  801b70:	56                   	push   %esi
  801b71:	68 00 50 80 00       	push   $0x805000
  801b76:	e8 8d ee ff ff       	call   800a08 <strcpy>
	fsipcbuf.open.req_omode = mode;
  801b7b:	8b 45 0c             	mov    0xc(%ebp),%eax
  801b7e:	a3 00 54 80 00       	mov    %eax,0x805400
	if ((r = fsipc(FSREQ_OPEN, fd)) < 0) {
  801b83:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801b86:	b8 01 00 00 00       	mov    $0x1,%eax
  801b8b:	e8 db fd ff ff       	call   80196b <fsipc>
  801b90:	89 c3                	mov    %eax,%ebx
  801b92:	83 c4 10             	add    $0x10,%esp
  801b95:	85 c0                	test   %eax,%eax
  801b97:	78 19                	js     801bb2 <open+0x79>
	return fd2num(fd);
  801b99:	83 ec 0c             	sub    $0xc,%esp
  801b9c:	ff 75 f4             	pushl  -0xc(%ebp)
  801b9f:	e8 f8 f7 ff ff       	call   80139c <fd2num>
  801ba4:	89 c3                	mov    %eax,%ebx
  801ba6:	83 c4 10             	add    $0x10,%esp
}
  801ba9:	89 d8                	mov    %ebx,%eax
  801bab:	8d 65 f8             	lea    -0x8(%ebp),%esp
  801bae:	5b                   	pop    %ebx
  801baf:	5e                   	pop    %esi
  801bb0:	5d                   	pop    %ebp
  801bb1:	c3                   	ret    
		fd_close(fd, 0);
  801bb2:	83 ec 08             	sub    $0x8,%esp
  801bb5:	6a 00                	push   $0x0
  801bb7:	ff 75 f4             	pushl  -0xc(%ebp)
  801bba:	e8 10 f9 ff ff       	call   8014cf <fd_close>
		return r;
  801bbf:	83 c4 10             	add    $0x10,%esp
  801bc2:	eb e5                	jmp    801ba9 <open+0x70>
		return -E_BAD_PATH;
  801bc4:	bb f4 ff ff ff       	mov    $0xfffffff4,%ebx
  801bc9:	eb de                	jmp    801ba9 <open+0x70>

00801bcb <sync>:


// Synchronize disk with buffer cache
int
sync(void)
{
  801bcb:	f3 0f 1e fb          	endbr32 
  801bcf:	55                   	push   %ebp
  801bd0:	89 e5                	mov    %esp,%ebp
  801bd2:	83 ec 08             	sub    $0x8,%esp
	// Ask the file server to update the disk
	// by writing any dirty blocks in the buffer cache.

	return fsipc(FSREQ_SYNC, NULL);
  801bd5:	ba 00 00 00 00       	mov    $0x0,%edx
  801bda:	b8 08 00 00 00       	mov    $0x8,%eax
  801bdf:	e8 87 fd ff ff       	call   80196b <fsipc>
}
  801be4:	c9                   	leave  
  801be5:	c3                   	ret    

00801be6 <devpipe_stat>:
	return i;
}

static int
devpipe_stat(struct Fd *fd, struct Stat *stat)
{
  801be6:	f3 0f 1e fb          	endbr32 
  801bea:	55                   	push   %ebp
  801beb:	89 e5                	mov    %esp,%ebp
  801bed:	56                   	push   %esi
  801bee:	53                   	push   %ebx
  801bef:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	struct Pipe *p = (struct Pipe*) fd2data(fd);
  801bf2:	83 ec 0c             	sub    $0xc,%esp
  801bf5:	ff 75 08             	pushl  0x8(%ebp)
  801bf8:	e8 b3 f7 ff ff       	call   8013b0 <fd2data>
  801bfd:	89 c6                	mov    %eax,%esi
	strcpy(stat->st_name, "<pipe>");
  801bff:	83 c4 08             	add    $0x8,%esp
  801c02:	68 5b 2c 80 00       	push   $0x802c5b
  801c07:	53                   	push   %ebx
  801c08:	e8 fb ed ff ff       	call   800a08 <strcpy>
	stat->st_size = p->p_wpos - p->p_rpos;
  801c0d:	8b 46 04             	mov    0x4(%esi),%eax
  801c10:	2b 06                	sub    (%esi),%eax
  801c12:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	stat->st_isdir = 0;
  801c18:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  801c1f:	00 00 00 
	stat->st_dev = &devpipe;
  801c22:	c7 83 88 00 00 00 24 	movl   $0x803024,0x88(%ebx)
  801c29:	30 80 00 
	return 0;
}
  801c2c:	b8 00 00 00 00       	mov    $0x0,%eax
  801c31:	8d 65 f8             	lea    -0x8(%ebp),%esp
  801c34:	5b                   	pop    %ebx
  801c35:	5e                   	pop    %esi
  801c36:	5d                   	pop    %ebp
  801c37:	c3                   	ret    

00801c38 <devpipe_close>:

static int
devpipe_close(struct Fd *fd)
{
  801c38:	f3 0f 1e fb          	endbr32 
  801c3c:	55                   	push   %ebp
  801c3d:	89 e5                	mov    %esp,%ebp
  801c3f:	53                   	push   %ebx
  801c40:	83 ec 0c             	sub    $0xc,%esp
  801c43:	8b 5d 08             	mov    0x8(%ebp),%ebx
	(void) sys_page_unmap(0, fd);
  801c46:	53                   	push   %ebx
  801c47:	6a 00                	push   $0x0
  801c49:	e8 89 f2 ff ff       	call   800ed7 <sys_page_unmap>
	return sys_page_unmap(0, fd2data(fd));
  801c4e:	89 1c 24             	mov    %ebx,(%esp)
  801c51:	e8 5a f7 ff ff       	call   8013b0 <fd2data>
  801c56:	83 c4 08             	add    $0x8,%esp
  801c59:	50                   	push   %eax
  801c5a:	6a 00                	push   $0x0
  801c5c:	e8 76 f2 ff ff       	call   800ed7 <sys_page_unmap>
}
  801c61:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  801c64:	c9                   	leave  
  801c65:	c3                   	ret    

00801c66 <_pipeisclosed>:
{
  801c66:	55                   	push   %ebp
  801c67:	89 e5                	mov    %esp,%ebp
  801c69:	57                   	push   %edi
  801c6a:	56                   	push   %esi
  801c6b:	53                   	push   %ebx
  801c6c:	83 ec 1c             	sub    $0x1c,%esp
  801c6f:	89 c7                	mov    %eax,%edi
  801c71:	89 d6                	mov    %edx,%esi
		n = thisenv->env_runs;
  801c73:	a1 04 40 80 00       	mov    0x804004,%eax
  801c78:	8b 58 58             	mov    0x58(%eax),%ebx
		ret = pageref(fd) == pageref(p);
  801c7b:	83 ec 0c             	sub    $0xc,%esp
  801c7e:	57                   	push   %edi
  801c7f:	e8 67 06 00 00       	call   8022eb <pageref>
  801c84:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  801c87:	89 34 24             	mov    %esi,(%esp)
  801c8a:	e8 5c 06 00 00       	call   8022eb <pageref>
		nn = thisenv->env_runs;
  801c8f:	8b 15 04 40 80 00    	mov    0x804004,%edx
  801c95:	8b 4a 58             	mov    0x58(%edx),%ecx
		if (n == nn)
  801c98:	83 c4 10             	add    $0x10,%esp
  801c9b:	39 cb                	cmp    %ecx,%ebx
  801c9d:	74 1b                	je     801cba <_pipeisclosed+0x54>
		if (n != nn && ret == 1)
  801c9f:	39 45 e4             	cmp    %eax,-0x1c(%ebp)
  801ca2:	75 cf                	jne    801c73 <_pipeisclosed+0xd>
			cprintf("pipe race avoided\n", n, thisenv->env_runs, ret);
  801ca4:	8b 42 58             	mov    0x58(%edx),%eax
  801ca7:	6a 01                	push   $0x1
  801ca9:	50                   	push   %eax
  801caa:	53                   	push   %ebx
  801cab:	68 62 2c 80 00       	push   $0x802c62
  801cb0:	e8 7a e7 ff ff       	call   80042f <cprintf>
  801cb5:	83 c4 10             	add    $0x10,%esp
  801cb8:	eb b9                	jmp    801c73 <_pipeisclosed+0xd>
		ret = pageref(fd) == pageref(p);
  801cba:	39 45 e4             	cmp    %eax,-0x1c(%ebp)
  801cbd:	0f 94 c0             	sete   %al
  801cc0:	0f b6 c0             	movzbl %al,%eax
}
  801cc3:	8d 65 f4             	lea    -0xc(%ebp),%esp
  801cc6:	5b                   	pop    %ebx
  801cc7:	5e                   	pop    %esi
  801cc8:	5f                   	pop    %edi
  801cc9:	5d                   	pop    %ebp
  801cca:	c3                   	ret    

00801ccb <devpipe_write>:
{
  801ccb:	f3 0f 1e fb          	endbr32 
  801ccf:	55                   	push   %ebp
  801cd0:	89 e5                	mov    %esp,%ebp
  801cd2:	57                   	push   %edi
  801cd3:	56                   	push   %esi
  801cd4:	53                   	push   %ebx
  801cd5:	83 ec 28             	sub    $0x28,%esp
  801cd8:	8b 75 08             	mov    0x8(%ebp),%esi
	p = (struct Pipe*) fd2data(fd);
  801cdb:	56                   	push   %esi
  801cdc:	e8 cf f6 ff ff       	call   8013b0 <fd2data>
  801ce1:	89 c3                	mov    %eax,%ebx
	for (i = 0; i < n; i++) {
  801ce3:	83 c4 10             	add    $0x10,%esp
  801ce6:	bf 00 00 00 00       	mov    $0x0,%edi
  801ceb:	3b 7d 10             	cmp    0x10(%ebp),%edi
  801cee:	74 4f                	je     801d3f <devpipe_write+0x74>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  801cf0:	8b 43 04             	mov    0x4(%ebx),%eax
  801cf3:	8b 0b                	mov    (%ebx),%ecx
  801cf5:	8d 51 20             	lea    0x20(%ecx),%edx
  801cf8:	39 d0                	cmp    %edx,%eax
  801cfa:	72 14                	jb     801d10 <devpipe_write+0x45>
			if (_pipeisclosed(fd, p))
  801cfc:	89 da                	mov    %ebx,%edx
  801cfe:	89 f0                	mov    %esi,%eax
  801d00:	e8 61 ff ff ff       	call   801c66 <_pipeisclosed>
  801d05:	85 c0                	test   %eax,%eax
  801d07:	75 3b                	jne    801d44 <devpipe_write+0x79>
			sys_yield();
  801d09:	e8 19 f1 ff ff       	call   800e27 <sys_yield>
  801d0e:	eb e0                	jmp    801cf0 <devpipe_write+0x25>
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
  801d10:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801d13:	0f b6 0c 39          	movzbl (%ecx,%edi,1),%ecx
  801d17:	88 4d e7             	mov    %cl,-0x19(%ebp)
  801d1a:	89 c2                	mov    %eax,%edx
  801d1c:	c1 fa 1f             	sar    $0x1f,%edx
  801d1f:	89 d1                	mov    %edx,%ecx
  801d21:	c1 e9 1b             	shr    $0x1b,%ecx
  801d24:	8d 14 08             	lea    (%eax,%ecx,1),%edx
  801d27:	83 e2 1f             	and    $0x1f,%edx
  801d2a:	29 ca                	sub    %ecx,%edx
  801d2c:	0f b6 4d e7          	movzbl -0x19(%ebp),%ecx
  801d30:	88 4c 13 08          	mov    %cl,0x8(%ebx,%edx,1)
		p->p_wpos++;
  801d34:	83 c0 01             	add    $0x1,%eax
  801d37:	89 43 04             	mov    %eax,0x4(%ebx)
	for (i = 0; i < n; i++) {
  801d3a:	83 c7 01             	add    $0x1,%edi
  801d3d:	eb ac                	jmp    801ceb <devpipe_write+0x20>
	return i;
  801d3f:	8b 45 10             	mov    0x10(%ebp),%eax
  801d42:	eb 05                	jmp    801d49 <devpipe_write+0x7e>
				return 0;
  801d44:	b8 00 00 00 00       	mov    $0x0,%eax
}
  801d49:	8d 65 f4             	lea    -0xc(%ebp),%esp
  801d4c:	5b                   	pop    %ebx
  801d4d:	5e                   	pop    %esi
  801d4e:	5f                   	pop    %edi
  801d4f:	5d                   	pop    %ebp
  801d50:	c3                   	ret    

00801d51 <devpipe_read>:
{
  801d51:	f3 0f 1e fb          	endbr32 
  801d55:	55                   	push   %ebp
  801d56:	89 e5                	mov    %esp,%ebp
  801d58:	57                   	push   %edi
  801d59:	56                   	push   %esi
  801d5a:	53                   	push   %ebx
  801d5b:	83 ec 18             	sub    $0x18,%esp
  801d5e:	8b 7d 08             	mov    0x8(%ebp),%edi
	p = (struct Pipe*)fd2data(fd);
  801d61:	57                   	push   %edi
  801d62:	e8 49 f6 ff ff       	call   8013b0 <fd2data>
  801d67:	89 c3                	mov    %eax,%ebx
	for (i = 0; i < n; i++) {
  801d69:	83 c4 10             	add    $0x10,%esp
  801d6c:	be 00 00 00 00       	mov    $0x0,%esi
  801d71:	3b 75 10             	cmp    0x10(%ebp),%esi
  801d74:	75 14                	jne    801d8a <devpipe_read+0x39>
	return i;
  801d76:	8b 45 10             	mov    0x10(%ebp),%eax
  801d79:	eb 02                	jmp    801d7d <devpipe_read+0x2c>
				return i;
  801d7b:	89 f0                	mov    %esi,%eax
}
  801d7d:	8d 65 f4             	lea    -0xc(%ebp),%esp
  801d80:	5b                   	pop    %ebx
  801d81:	5e                   	pop    %esi
  801d82:	5f                   	pop    %edi
  801d83:	5d                   	pop    %ebp
  801d84:	c3                   	ret    
			sys_yield();
  801d85:	e8 9d f0 ff ff       	call   800e27 <sys_yield>
		while (p->p_rpos == p->p_wpos) {
  801d8a:	8b 03                	mov    (%ebx),%eax
  801d8c:	3b 43 04             	cmp    0x4(%ebx),%eax
  801d8f:	75 18                	jne    801da9 <devpipe_read+0x58>
			if (i > 0)
  801d91:	85 f6                	test   %esi,%esi
  801d93:	75 e6                	jne    801d7b <devpipe_read+0x2a>
			if (_pipeisclosed(fd, p))
  801d95:	89 da                	mov    %ebx,%edx
  801d97:	89 f8                	mov    %edi,%eax
  801d99:	e8 c8 fe ff ff       	call   801c66 <_pipeisclosed>
  801d9e:	85 c0                	test   %eax,%eax
  801da0:	74 e3                	je     801d85 <devpipe_read+0x34>
				return 0;
  801da2:	b8 00 00 00 00       	mov    $0x0,%eax
  801da7:	eb d4                	jmp    801d7d <devpipe_read+0x2c>
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
  801da9:	99                   	cltd   
  801daa:	c1 ea 1b             	shr    $0x1b,%edx
  801dad:	01 d0                	add    %edx,%eax
  801daf:	83 e0 1f             	and    $0x1f,%eax
  801db2:	29 d0                	sub    %edx,%eax
  801db4:	0f b6 44 03 08       	movzbl 0x8(%ebx,%eax,1),%eax
  801db9:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801dbc:	88 04 31             	mov    %al,(%ecx,%esi,1)
		p->p_rpos++;
  801dbf:	83 03 01             	addl   $0x1,(%ebx)
	for (i = 0; i < n; i++) {
  801dc2:	83 c6 01             	add    $0x1,%esi
  801dc5:	eb aa                	jmp    801d71 <devpipe_read+0x20>

00801dc7 <pipe>:
{
  801dc7:	f3 0f 1e fb          	endbr32 
  801dcb:	55                   	push   %ebp
  801dcc:	89 e5                	mov    %esp,%ebp
  801dce:	56                   	push   %esi
  801dcf:	53                   	push   %ebx
  801dd0:	83 ec 1c             	sub    $0x1c,%esp
	if ((r = fd_alloc(&fd0)) < 0
  801dd3:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801dd6:	50                   	push   %eax
  801dd7:	e8 ef f5 ff ff       	call   8013cb <fd_alloc>
  801ddc:	89 c3                	mov    %eax,%ebx
  801dde:	83 c4 10             	add    $0x10,%esp
  801de1:	85 c0                	test   %eax,%eax
  801de3:	0f 88 23 01 00 00    	js     801f0c <pipe+0x145>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  801de9:	83 ec 04             	sub    $0x4,%esp
  801dec:	68 07 04 00 00       	push   $0x407
  801df1:	ff 75 f4             	pushl  -0xc(%ebp)
  801df4:	6a 00                	push   $0x0
  801df6:	e8 4f f0 ff ff       	call   800e4a <sys_page_alloc>
  801dfb:	89 c3                	mov    %eax,%ebx
  801dfd:	83 c4 10             	add    $0x10,%esp
  801e00:	85 c0                	test   %eax,%eax
  801e02:	0f 88 04 01 00 00    	js     801f0c <pipe+0x145>
	if ((r = fd_alloc(&fd1)) < 0
  801e08:	83 ec 0c             	sub    $0xc,%esp
  801e0b:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801e0e:	50                   	push   %eax
  801e0f:	e8 b7 f5 ff ff       	call   8013cb <fd_alloc>
  801e14:	89 c3                	mov    %eax,%ebx
  801e16:	83 c4 10             	add    $0x10,%esp
  801e19:	85 c0                	test   %eax,%eax
  801e1b:	0f 88 db 00 00 00    	js     801efc <pipe+0x135>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  801e21:	83 ec 04             	sub    $0x4,%esp
  801e24:	68 07 04 00 00       	push   $0x407
  801e29:	ff 75 f0             	pushl  -0x10(%ebp)
  801e2c:	6a 00                	push   $0x0
  801e2e:	e8 17 f0 ff ff       	call   800e4a <sys_page_alloc>
  801e33:	89 c3                	mov    %eax,%ebx
  801e35:	83 c4 10             	add    $0x10,%esp
  801e38:	85 c0                	test   %eax,%eax
  801e3a:	0f 88 bc 00 00 00    	js     801efc <pipe+0x135>
	va = fd2data(fd0);
  801e40:	83 ec 0c             	sub    $0xc,%esp
  801e43:	ff 75 f4             	pushl  -0xc(%ebp)
  801e46:	e8 65 f5 ff ff       	call   8013b0 <fd2data>
  801e4b:	89 c6                	mov    %eax,%esi
	if ((r = sys_page_alloc(0, va, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  801e4d:	83 c4 0c             	add    $0xc,%esp
  801e50:	68 07 04 00 00       	push   $0x407
  801e55:	50                   	push   %eax
  801e56:	6a 00                	push   $0x0
  801e58:	e8 ed ef ff ff       	call   800e4a <sys_page_alloc>
  801e5d:	89 c3                	mov    %eax,%ebx
  801e5f:	83 c4 10             	add    $0x10,%esp
  801e62:	85 c0                	test   %eax,%eax
  801e64:	0f 88 82 00 00 00    	js     801eec <pipe+0x125>
	if ((r = sys_page_map(0, va, 0, fd2data(fd1), PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  801e6a:	83 ec 0c             	sub    $0xc,%esp
  801e6d:	ff 75 f0             	pushl  -0x10(%ebp)
  801e70:	e8 3b f5 ff ff       	call   8013b0 <fd2data>
  801e75:	c7 04 24 07 04 00 00 	movl   $0x407,(%esp)
  801e7c:	50                   	push   %eax
  801e7d:	6a 00                	push   $0x0
  801e7f:	56                   	push   %esi
  801e80:	6a 00                	push   $0x0
  801e82:	e8 0a f0 ff ff       	call   800e91 <sys_page_map>
  801e87:	89 c3                	mov    %eax,%ebx
  801e89:	83 c4 20             	add    $0x20,%esp
  801e8c:	85 c0                	test   %eax,%eax
  801e8e:	78 4e                	js     801ede <pipe+0x117>
	fd0->fd_dev_id = devpipe.dev_id;
  801e90:	a1 24 30 80 00       	mov    0x803024,%eax
  801e95:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801e98:	89 02                	mov    %eax,(%edx)
	fd0->fd_omode = O_RDONLY;
  801e9a:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801e9d:	c7 42 08 00 00 00 00 	movl   $0x0,0x8(%edx)
	fd1->fd_dev_id = devpipe.dev_id;
  801ea4:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801ea7:	89 02                	mov    %eax,(%edx)
	fd1->fd_omode = O_WRONLY;
  801ea9:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801eac:	c7 40 08 01 00 00 00 	movl   $0x1,0x8(%eax)
	pfd[0] = fd2num(fd0);
  801eb3:	83 ec 0c             	sub    $0xc,%esp
  801eb6:	ff 75 f4             	pushl  -0xc(%ebp)
  801eb9:	e8 de f4 ff ff       	call   80139c <fd2num>
  801ebe:	8b 4d 08             	mov    0x8(%ebp),%ecx
  801ec1:	89 01                	mov    %eax,(%ecx)
	pfd[1] = fd2num(fd1);
  801ec3:	83 c4 04             	add    $0x4,%esp
  801ec6:	ff 75 f0             	pushl  -0x10(%ebp)
  801ec9:	e8 ce f4 ff ff       	call   80139c <fd2num>
  801ece:	8b 4d 08             	mov    0x8(%ebp),%ecx
  801ed1:	89 41 04             	mov    %eax,0x4(%ecx)
	return 0;
  801ed4:	83 c4 10             	add    $0x10,%esp
  801ed7:	bb 00 00 00 00       	mov    $0x0,%ebx
  801edc:	eb 2e                	jmp    801f0c <pipe+0x145>
	sys_page_unmap(0, va);
  801ede:	83 ec 08             	sub    $0x8,%esp
  801ee1:	56                   	push   %esi
  801ee2:	6a 00                	push   $0x0
  801ee4:	e8 ee ef ff ff       	call   800ed7 <sys_page_unmap>
  801ee9:	83 c4 10             	add    $0x10,%esp
	sys_page_unmap(0, fd1);
  801eec:	83 ec 08             	sub    $0x8,%esp
  801eef:	ff 75 f0             	pushl  -0x10(%ebp)
  801ef2:	6a 00                	push   $0x0
  801ef4:	e8 de ef ff ff       	call   800ed7 <sys_page_unmap>
  801ef9:	83 c4 10             	add    $0x10,%esp
	sys_page_unmap(0, fd0);
  801efc:	83 ec 08             	sub    $0x8,%esp
  801eff:	ff 75 f4             	pushl  -0xc(%ebp)
  801f02:	6a 00                	push   $0x0
  801f04:	e8 ce ef ff ff       	call   800ed7 <sys_page_unmap>
  801f09:	83 c4 10             	add    $0x10,%esp
}
  801f0c:	89 d8                	mov    %ebx,%eax
  801f0e:	8d 65 f8             	lea    -0x8(%ebp),%esp
  801f11:	5b                   	pop    %ebx
  801f12:	5e                   	pop    %esi
  801f13:	5d                   	pop    %ebp
  801f14:	c3                   	ret    

00801f15 <pipeisclosed>:
{
  801f15:	f3 0f 1e fb          	endbr32 
  801f19:	55                   	push   %ebp
  801f1a:	89 e5                	mov    %esp,%ebp
  801f1c:	83 ec 20             	sub    $0x20,%esp
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  801f1f:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801f22:	50                   	push   %eax
  801f23:	ff 75 08             	pushl  0x8(%ebp)
  801f26:	e8 f6 f4 ff ff       	call   801421 <fd_lookup>
  801f2b:	83 c4 10             	add    $0x10,%esp
  801f2e:	85 c0                	test   %eax,%eax
  801f30:	78 18                	js     801f4a <pipeisclosed+0x35>
	p = (struct Pipe*) fd2data(fd);
  801f32:	83 ec 0c             	sub    $0xc,%esp
  801f35:	ff 75 f4             	pushl  -0xc(%ebp)
  801f38:	e8 73 f4 ff ff       	call   8013b0 <fd2data>
  801f3d:	89 c2                	mov    %eax,%edx
	return _pipeisclosed(fd, p);
  801f3f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801f42:	e8 1f fd ff ff       	call   801c66 <_pipeisclosed>
  801f47:	83 c4 10             	add    $0x10,%esp
}
  801f4a:	c9                   	leave  
  801f4b:	c3                   	ret    

00801f4c <wait>:
#include <inc/lib.h>

// Waits until 'envid' exits.
void
wait(envid_t envid)
{
  801f4c:	f3 0f 1e fb          	endbr32 
  801f50:	55                   	push   %ebp
  801f51:	89 e5                	mov    %esp,%ebp
  801f53:	56                   	push   %esi
  801f54:	53                   	push   %ebx
  801f55:	8b 75 08             	mov    0x8(%ebp),%esi
	const volatile struct Env *e;

	assert(envid != 0);
  801f58:	85 f6                	test   %esi,%esi
  801f5a:	74 13                	je     801f6f <wait+0x23>
	e = &envs[ENVX(envid)];
  801f5c:	89 f3                	mov    %esi,%ebx
  801f5e:	81 e3 ff 03 00 00    	and    $0x3ff,%ebx
	while (e->env_id == envid && e->env_status != ENV_FREE)
  801f64:	6b db 7c             	imul   $0x7c,%ebx,%ebx
  801f67:	81 c3 00 00 c0 ee    	add    $0xeec00000,%ebx
  801f6d:	eb 1b                	jmp    801f8a <wait+0x3e>
	assert(envid != 0);
  801f6f:	68 7a 2c 80 00       	push   $0x802c7a
  801f74:	68 2f 2c 80 00       	push   $0x802c2f
  801f79:	6a 09                	push   $0x9
  801f7b:	68 85 2c 80 00       	push   $0x802c85
  801f80:	e8 c3 e3 ff ff       	call   800348 <_panic>
		sys_yield();
  801f85:	e8 9d ee ff ff       	call   800e27 <sys_yield>
	while (e->env_id == envid && e->env_status != ENV_FREE)
  801f8a:	8b 43 48             	mov    0x48(%ebx),%eax
  801f8d:	39 f0                	cmp    %esi,%eax
  801f8f:	75 07                	jne    801f98 <wait+0x4c>
  801f91:	8b 43 54             	mov    0x54(%ebx),%eax
  801f94:	85 c0                	test   %eax,%eax
  801f96:	75 ed                	jne    801f85 <wait+0x39>
}
  801f98:	8d 65 f8             	lea    -0x8(%ebp),%esp
  801f9b:	5b                   	pop    %ebx
  801f9c:	5e                   	pop    %esi
  801f9d:	5d                   	pop    %ebp
  801f9e:	c3                   	ret    

00801f9f <devcons_close>:
	return tot;
}

static int
devcons_close(struct Fd *fd)
{
  801f9f:	f3 0f 1e fb          	endbr32 
	USED(fd);

	return 0;
}
  801fa3:	b8 00 00 00 00       	mov    $0x0,%eax
  801fa8:	c3                   	ret    

00801fa9 <devcons_stat>:

static int
devcons_stat(struct Fd *fd, struct Stat *stat)
{
  801fa9:	f3 0f 1e fb          	endbr32 
  801fad:	55                   	push   %ebp
  801fae:	89 e5                	mov    %esp,%ebp
  801fb0:	83 ec 10             	sub    $0x10,%esp
	strcpy(stat->st_name, "<cons>");
  801fb3:	68 90 2c 80 00       	push   $0x802c90
  801fb8:	ff 75 0c             	pushl  0xc(%ebp)
  801fbb:	e8 48 ea ff ff       	call   800a08 <strcpy>
	return 0;
}
  801fc0:	b8 00 00 00 00       	mov    $0x0,%eax
  801fc5:	c9                   	leave  
  801fc6:	c3                   	ret    

00801fc7 <devcons_write>:
{
  801fc7:	f3 0f 1e fb          	endbr32 
  801fcb:	55                   	push   %ebp
  801fcc:	89 e5                	mov    %esp,%ebp
  801fce:	57                   	push   %edi
  801fcf:	56                   	push   %esi
  801fd0:	53                   	push   %ebx
  801fd1:	81 ec 8c 00 00 00    	sub    $0x8c,%esp
	for (tot = 0; tot < n; tot += m) {
  801fd7:	be 00 00 00 00       	mov    $0x0,%esi
		memmove(buf, (char*)vbuf + tot, m);
  801fdc:	8d bd 68 ff ff ff    	lea    -0x98(%ebp),%edi
	for (tot = 0; tot < n; tot += m) {
  801fe2:	3b 75 10             	cmp    0x10(%ebp),%esi
  801fe5:	73 31                	jae    802018 <devcons_write+0x51>
		m = n - tot;
  801fe7:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801fea:	29 f3                	sub    %esi,%ebx
  801fec:	83 fb 7f             	cmp    $0x7f,%ebx
  801fef:	b8 7f 00 00 00       	mov    $0x7f,%eax
  801ff4:	0f 47 d8             	cmova  %eax,%ebx
		memmove(buf, (char*)vbuf + tot, m);
  801ff7:	83 ec 04             	sub    $0x4,%esp
  801ffa:	53                   	push   %ebx
  801ffb:	89 f0                	mov    %esi,%eax
  801ffd:	03 45 0c             	add    0xc(%ebp),%eax
  802000:	50                   	push   %eax
  802001:	57                   	push   %edi
  802002:	e8 b7 eb ff ff       	call   800bbe <memmove>
		sys_cputs(buf, m);
  802007:	83 c4 08             	add    $0x8,%esp
  80200a:	53                   	push   %ebx
  80200b:	57                   	push   %edi
  80200c:	e8 69 ed ff ff       	call   800d7a <sys_cputs>
	for (tot = 0; tot < n; tot += m) {
  802011:	01 de                	add    %ebx,%esi
  802013:	83 c4 10             	add    $0x10,%esp
  802016:	eb ca                	jmp    801fe2 <devcons_write+0x1b>
}
  802018:	89 f0                	mov    %esi,%eax
  80201a:	8d 65 f4             	lea    -0xc(%ebp),%esp
  80201d:	5b                   	pop    %ebx
  80201e:	5e                   	pop    %esi
  80201f:	5f                   	pop    %edi
  802020:	5d                   	pop    %ebp
  802021:	c3                   	ret    

00802022 <devcons_read>:
{
  802022:	f3 0f 1e fb          	endbr32 
  802026:	55                   	push   %ebp
  802027:	89 e5                	mov    %esp,%ebp
  802029:	83 ec 08             	sub    $0x8,%esp
  80202c:	b8 00 00 00 00       	mov    $0x0,%eax
	if (n == 0)
  802031:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802035:	74 21                	je     802058 <devcons_read+0x36>
	while ((c = sys_cgetc()) == 0)
  802037:	e8 60 ed ff ff       	call   800d9c <sys_cgetc>
  80203c:	85 c0                	test   %eax,%eax
  80203e:	75 07                	jne    802047 <devcons_read+0x25>
		sys_yield();
  802040:	e8 e2 ed ff ff       	call   800e27 <sys_yield>
  802045:	eb f0                	jmp    802037 <devcons_read+0x15>
	if (c < 0)
  802047:	78 0f                	js     802058 <devcons_read+0x36>
	if (c == 0x04)	// ctl-d is eof
  802049:	83 f8 04             	cmp    $0x4,%eax
  80204c:	74 0c                	je     80205a <devcons_read+0x38>
	*(char*)vbuf = c;
  80204e:	8b 55 0c             	mov    0xc(%ebp),%edx
  802051:	88 02                	mov    %al,(%edx)
	return 1;
  802053:	b8 01 00 00 00       	mov    $0x1,%eax
}
  802058:	c9                   	leave  
  802059:	c3                   	ret    
		return 0;
  80205a:	b8 00 00 00 00       	mov    $0x0,%eax
  80205f:	eb f7                	jmp    802058 <devcons_read+0x36>

00802061 <cputchar>:
{
  802061:	f3 0f 1e fb          	endbr32 
  802065:	55                   	push   %ebp
  802066:	89 e5                	mov    %esp,%ebp
  802068:	83 ec 20             	sub    $0x20,%esp
	char c = ch;
  80206b:	8b 45 08             	mov    0x8(%ebp),%eax
  80206e:	88 45 f7             	mov    %al,-0x9(%ebp)
	sys_cputs(&c, 1);
  802071:	6a 01                	push   $0x1
  802073:	8d 45 f7             	lea    -0x9(%ebp),%eax
  802076:	50                   	push   %eax
  802077:	e8 fe ec ff ff       	call   800d7a <sys_cputs>
}
  80207c:	83 c4 10             	add    $0x10,%esp
  80207f:	c9                   	leave  
  802080:	c3                   	ret    

00802081 <getchar>:
{
  802081:	f3 0f 1e fb          	endbr32 
  802085:	55                   	push   %ebp
  802086:	89 e5                	mov    %esp,%ebp
  802088:	83 ec 1c             	sub    $0x1c,%esp
	r = read(0, &c, 1);
  80208b:	6a 01                	push   $0x1
  80208d:	8d 45 f7             	lea    -0x9(%ebp),%eax
  802090:	50                   	push   %eax
  802091:	6a 00                	push   $0x0
  802093:	e8 0c f6 ff ff       	call   8016a4 <read>
	if (r < 0)
  802098:	83 c4 10             	add    $0x10,%esp
  80209b:	85 c0                	test   %eax,%eax
  80209d:	78 06                	js     8020a5 <getchar+0x24>
	if (r < 1)
  80209f:	74 06                	je     8020a7 <getchar+0x26>
	return c;
  8020a1:	0f b6 45 f7          	movzbl -0x9(%ebp),%eax
}
  8020a5:	c9                   	leave  
  8020a6:	c3                   	ret    
		return -E_EOF;
  8020a7:	b8 f8 ff ff ff       	mov    $0xfffffff8,%eax
  8020ac:	eb f7                	jmp    8020a5 <getchar+0x24>

008020ae <iscons>:
{
  8020ae:	f3 0f 1e fb          	endbr32 
  8020b2:	55                   	push   %ebp
  8020b3:	89 e5                	mov    %esp,%ebp
  8020b5:	83 ec 20             	sub    $0x20,%esp
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  8020b8:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8020bb:	50                   	push   %eax
  8020bc:	ff 75 08             	pushl  0x8(%ebp)
  8020bf:	e8 5d f3 ff ff       	call   801421 <fd_lookup>
  8020c4:	83 c4 10             	add    $0x10,%esp
  8020c7:	85 c0                	test   %eax,%eax
  8020c9:	78 11                	js     8020dc <iscons+0x2e>
	return fd->fd_dev_id == devcons.dev_id;
  8020cb:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8020ce:	8b 15 40 30 80 00    	mov    0x803040,%edx
  8020d4:	39 10                	cmp    %edx,(%eax)
  8020d6:	0f 94 c0             	sete   %al
  8020d9:	0f b6 c0             	movzbl %al,%eax
}
  8020dc:	c9                   	leave  
  8020dd:	c3                   	ret    

008020de <opencons>:
{
  8020de:	f3 0f 1e fb          	endbr32 
  8020e2:	55                   	push   %ebp
  8020e3:	89 e5                	mov    %esp,%ebp
  8020e5:	83 ec 24             	sub    $0x24,%esp
	if ((r = fd_alloc(&fd)) < 0)
  8020e8:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8020eb:	50                   	push   %eax
  8020ec:	e8 da f2 ff ff       	call   8013cb <fd_alloc>
  8020f1:	83 c4 10             	add    $0x10,%esp
  8020f4:	85 c0                	test   %eax,%eax
  8020f6:	78 3a                	js     802132 <opencons+0x54>
	if ((r = sys_page_alloc(0, fd, PTE_P|PTE_U|PTE_W|PTE_SHARE)) < 0)
  8020f8:	83 ec 04             	sub    $0x4,%esp
  8020fb:	68 07 04 00 00       	push   $0x407
  802100:	ff 75 f4             	pushl  -0xc(%ebp)
  802103:	6a 00                	push   $0x0
  802105:	e8 40 ed ff ff       	call   800e4a <sys_page_alloc>
  80210a:	83 c4 10             	add    $0x10,%esp
  80210d:	85 c0                	test   %eax,%eax
  80210f:	78 21                	js     802132 <opencons+0x54>
	fd->fd_dev_id = devcons.dev_id;
  802111:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802114:	8b 15 40 30 80 00    	mov    0x803040,%edx
  80211a:	89 10                	mov    %edx,(%eax)
	fd->fd_omode = O_RDWR;
  80211c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80211f:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	return fd2num(fd);
  802126:	83 ec 0c             	sub    $0xc,%esp
  802129:	50                   	push   %eax
  80212a:	e8 6d f2 ff ff       	call   80139c <fd2num>
  80212f:	83 c4 10             	add    $0x10,%esp
}
  802132:	c9                   	leave  
  802133:	c3                   	ret    

00802134 <set_pgfault_handler>:
// at UXSTACKTOP), and tell the kernel to call the assembly-language
// _pgfault_upcall routine when a page fault occurs.
//
void
set_pgfault_handler(void (*handler)(struct UTrapframe *utf))
{
  802134:	f3 0f 1e fb          	endbr32 
  802138:	55                   	push   %ebp
  802139:	89 e5                	mov    %esp,%ebp
  80213b:	83 ec 08             	sub    $0x8,%esp
	int r;

	if (_pgfault_handler == 0) {
  80213e:	83 3d 00 60 80 00 00 	cmpl   $0x0,0x806000
  802145:	74 27                	je     80216e <set_pgfault_handler+0x3a>
		if(sys_page_alloc(0,(void *)UXSTACKTOP-PGSIZE,PTE_W|PTE_U|PTE_P)<0)
			panic("set_pgfault_handler:sys_page_alloc failed");
	}

	// Save handler pointer for assembly to call.
	_pgfault_handler = handler;
  802147:	8b 45 08             	mov    0x8(%ebp),%eax
  80214a:	a3 00 60 80 00       	mov    %eax,0x806000
	if (sys_env_set_pgfault_upcall(thisenv->env_id,_pgfault_upcall)<0)	
  80214f:	a1 04 40 80 00       	mov    0x804004,%eax
  802154:	8b 40 48             	mov    0x48(%eax),%eax
  802157:	83 ec 08             	sub    $0x8,%esp
  80215a:	68 ae 21 80 00       	push   $0x8021ae
  80215f:	50                   	push   %eax
  802160:	e8 44 ee ff ff       	call   800fa9 <sys_env_set_pgfault_upcall>
  802165:	83 c4 10             	add    $0x10,%esp
  802168:	85 c0                	test   %eax,%eax
  80216a:	78 2e                	js     80219a <set_pgfault_handler+0x66>
        panic("set_pgfault_handler:sys_env_set_pgfault_upcall failed");
}
  80216c:	c9                   	leave  
  80216d:	c3                   	ret    
		if(sys_page_alloc(0,(void *)UXSTACKTOP-PGSIZE,PTE_W|PTE_U|PTE_P)<0)
  80216e:	83 ec 04             	sub    $0x4,%esp
  802171:	6a 07                	push   $0x7
  802173:	68 00 f0 bf ee       	push   $0xeebff000
  802178:	6a 00                	push   $0x0
  80217a:	e8 cb ec ff ff       	call   800e4a <sys_page_alloc>
  80217f:	83 c4 10             	add    $0x10,%esp
  802182:	85 c0                	test   %eax,%eax
  802184:	79 c1                	jns    802147 <set_pgfault_handler+0x13>
			panic("set_pgfault_handler:sys_page_alloc failed");
  802186:	83 ec 04             	sub    $0x4,%esp
  802189:	68 9c 2c 80 00       	push   $0x802c9c
  80218e:	6a 21                	push   $0x21
  802190:	68 fe 2c 80 00       	push   $0x802cfe
  802195:	e8 ae e1 ff ff       	call   800348 <_panic>
        panic("set_pgfault_handler:sys_env_set_pgfault_upcall failed");
  80219a:	83 ec 04             	sub    $0x4,%esp
  80219d:	68 c8 2c 80 00       	push   $0x802cc8
  8021a2:	6a 27                	push   $0x27
  8021a4:	68 fe 2c 80 00       	push   $0x802cfe
  8021a9:	e8 9a e1 ff ff       	call   800348 <_panic>

008021ae <_pgfault_upcall>:

.text
.globl _pgfault_upcall
_pgfault_upcall:
	// Call the C page fault handler.
	pushl %esp			// function argument: pointer to UTF
  8021ae:	54                   	push   %esp
	movl _pgfault_handler, %eax
  8021af:	a1 00 60 80 00       	mov    0x806000,%eax
	call *%eax
  8021b4:	ff d0                	call   *%eax
	addl $4, %esp			// pop function argument
  8021b6:	83 c4 04             	add    $0x4,%esp
	// may find that you have to rearrange your code in non-obvious
	// ways as registers become unavailable as scratch space.
	//
	// LAB 4: Your code here.
	//首先把此时的eip指针下移48个字节因为UTrapFrame的大小是48个字节
	movl 48(%esp), %ebp
  8021b9:	8b 6c 24 30          	mov    0x30(%esp),%ebp
    subl $4, %ebp		// UTrapFrame.utf_esp - 4 and store back 这里是由于之前预留了4个字节。
  8021bd:	83 ed 04             	sub    $0x4,%ebp
    movl %ebp, 48(%esp)	// 返回上一次的esp位置。
  8021c0:	89 6c 24 30          	mov    %ebp,0x30(%esp)

	// Restore the trap-time registers.  After you do this, you
	// can no longer modify any general-purpose registers.
	// LAB 4: Your code here.
	movl 40(%esp), %eax 
  8021c4:	8b 44 24 28          	mov    0x28(%esp),%eax
    movl %eax, (%ebp)
  8021c8:	89 45 00             	mov    %eax,0x0(%ebp)

	// Restore eflags from the stack.  After you do this, you can
	// no longer use arithmetic operations or anything else that
	// modifies eflags.
	// LAB 4: Your code here.
	addl $0x8, %esp         // Set %esp to the end of struct PushRegs
  8021cb:	83 c4 08             	add    $0x8,%esp
	popal                   // Restore the trap-time registers.(struct PushRegs)
  8021ce:	61                   	popa   

	// Switch back to the adjusted trap-time stack.
	// LAB 4: Your code here.
	addl $0x4, %esp         // now we are located at trap-time eip,so we have to increment %esp with 4.【跳过eip】
  8021cf:	83 c4 04             	add    $0x4,%esp
	popfl                   // Restore eflags register.	【pop eflags】
  8021d2:	9d                   	popf   
	popl %esp               // Just restore the adjusted trap-time stack pointer.
  8021d3:	5c                   	pop    %esp
							// 恢复esp

	// Return to re-execute the instruction that faulted.
	// LAB 4: Your code here.
	ret                     // We are now on the trap-time stack,since we have saved trap-time eip above trap-time esp,ret instruction will pop this trap-time eip to register %eip which known as PC at this time.Thus,we can return to re-execute the instruction that faulted.
  8021d4:	c3                   	ret    

008021d5 <ipc_recv>:
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value, since that's
//   a perfectly valid place to map a page.)
int32_t
ipc_recv(envid_t *from_env_store, void *pg, int *perm_store)
{
  8021d5:	f3 0f 1e fb          	endbr32 
  8021d9:	55                   	push   %ebp
  8021da:	89 e5                	mov    %esp,%ebp
  8021dc:	56                   	push   %esi
  8021dd:	53                   	push   %ebx
  8021de:	8b 75 08             	mov    0x8(%ebp),%esi
  8021e1:	8b 45 0c             	mov    0xc(%ebp),%eax
  8021e4:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// LAB 4: Your code here.
	int error;
	if(!pg)pg = (void *)UTOP; // 如果设置为UTOP，这个值其实可以比UTOP大，设置为这个值认为pg无效了，不会进行页面传递【共享页面的设置】，而是只进行值value的传递。
  8021e7:	85 c0                	test   %eax,%eax
  8021e9:	ba 00 00 c0 ee       	mov    $0xeec00000,%edx
  8021ee:	0f 44 c2             	cmove  %edx,%eax
	if((error = sys_ipc_recv(pg)) < 0){
  8021f1:	83 ec 0c             	sub    $0xc,%esp
  8021f4:	50                   	push   %eax
  8021f5:	e8 1c ee ff ff       	call   801016 <sys_ipc_recv>
  8021fa:	83 c4 10             	add    $0x10,%esp
  8021fd:	85 c0                	test   %eax,%eax
  8021ff:	78 3f                	js     802240 <ipc_recv+0x6b>
		if(from_env_store)*from_env_store = 0;
		if(perm_store)*perm_store = 0;
		return error;
	}

	thisenv = &envs[ENVX(sys_getenvid())]; // for lab4's challenge sfork().
  802201:	e8 fe eb ff ff       	call   800e04 <sys_getenvid>
  802206:	25 ff 03 00 00       	and    $0x3ff,%eax
  80220b:	6b d0 7c             	imul   $0x7c,%eax,%edx
  80220e:	81 c2 00 00 c0 ee    	add    $0xeec00000,%edx
  802214:	89 15 04 40 80 00    	mov    %edx,0x804004

	if(from_env_store)*from_env_store = thisenv->env_ipc_from;
  80221a:	85 f6                	test   %esi,%esi
  80221c:	74 05                	je     802223 <ipc_recv+0x4e>
  80221e:	8b 42 74             	mov    0x74(%edx),%eax
  802221:	89 06                	mov    %eax,(%esi)
	if(perm_store)*perm_store = thisenv->env_ipc_perm;
  802223:	85 db                	test   %ebx,%ebx
  802225:	74 0a                	je     802231 <ipc_recv+0x5c>
  802227:	a1 04 40 80 00       	mov    0x804004,%eax
  80222c:	8b 40 78             	mov    0x78(%eax),%eax
  80222f:	89 03                	mov    %eax,(%ebx)
	return thisenv->env_ipc_value;
  802231:	a1 04 40 80 00       	mov    0x804004,%eax
  802236:	8b 40 70             	mov    0x70(%eax),%eax
}
  802239:	8d 65 f8             	lea    -0x8(%ebp),%esp
  80223c:	5b                   	pop    %ebx
  80223d:	5e                   	pop    %esi
  80223e:	5d                   	pop    %ebp
  80223f:	c3                   	ret    
		if(from_env_store)*from_env_store = 0;
  802240:	85 f6                	test   %esi,%esi
  802242:	74 06                	je     80224a <ipc_recv+0x75>
  802244:	c7 06 00 00 00 00    	movl   $0x0,(%esi)
		if(perm_store)*perm_store = 0;
  80224a:	85 db                	test   %ebx,%ebx
  80224c:	74 eb                	je     802239 <ipc_recv+0x64>
  80224e:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  802254:	eb e3                	jmp    802239 <ipc_recv+0x64>

00802256 <ipc_send>:
//   Use sys_yield() to be CPU-friendly.
//   If 'pg' is null, pass sys_ipc_try_send a value that it will understand
//   as meaning "no page".  (Zero is not the right value.)
void
ipc_send(envid_t to_env, uint32_t val, void *pg, int perm)
{
  802256:	f3 0f 1e fb          	endbr32 
  80225a:	55                   	push   %ebp
  80225b:	89 e5                	mov    %esp,%ebp
  80225d:	57                   	push   %edi
  80225e:	56                   	push   %esi
  80225f:	53                   	push   %ebx
  802260:	83 ec 0c             	sub    $0xc,%esp
  802263:	8b 7d 08             	mov    0x8(%ebp),%edi
  802266:	8b 75 0c             	mov    0xc(%ebp),%esi
  802269:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// LAB 4: Your code here.
	if(!pg)pg = (void *)UTOP; // 不会进行页面共享，只会sending message。
  80226c:	85 db                	test   %ebx,%ebx
  80226e:	b8 00 00 c0 ee       	mov    $0xeec00000,%eax
  802273:	0f 44 d8             	cmove  %eax,%ebx
	int error;
	// Keep trying until it succeeds.
	while((error = sys_ipc_try_send(to_env, val, pg, perm)) < 0){
  802276:	ff 75 14             	pushl  0x14(%ebp)
  802279:	53                   	push   %ebx
  80227a:	56                   	push   %esi
  80227b:	57                   	push   %edi
  80227c:	e8 6e ed ff ff       	call   800fef <sys_ipc_try_send>
  802281:	83 c4 10             	add    $0x10,%esp
  802284:	85 c0                	test   %eax,%eax
  802286:	79 1e                	jns    8022a6 <ipc_send+0x50>
        //如果error是没有接收者，那么就会继续尝试send
		if(error != -E_IPC_NOT_RECV){
  802288:	83 f8 f9             	cmp    $0xfffffff9,%eax
  80228b:	75 07                	jne    802294 <ipc_send+0x3e>
			panic("sys_ipc_try_send:%e", error);
		}
        //但是不是一味的占用cpu，而是尝试一次就释放CPU，等待再次被调度，才会重新send，寻找receiver。
		sys_yield(); // To be CPU-friendly.
  80228d:	e8 95 eb ff ff       	call   800e27 <sys_yield>
  802292:	eb e2                	jmp    802276 <ipc_send+0x20>
			panic("sys_ipc_try_send:%e", error);
  802294:	50                   	push   %eax
  802295:	68 0c 2d 80 00       	push   $0x802d0c
  80229a:	6a 3b                	push   $0x3b
  80229c:	68 20 2d 80 00       	push   $0x802d20
  8022a1:	e8 a2 e0 ff ff       	call   800348 <_panic>
	}
}
  8022a6:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8022a9:	5b                   	pop    %ebx
  8022aa:	5e                   	pop    %esi
  8022ab:	5f                   	pop    %edi
  8022ac:	5d                   	pop    %ebp
  8022ad:	c3                   	ret    

008022ae <ipc_find_env>:
// Find the first environment of the given type.  We'll use this to
// find special environments.
// Returns 0 if no such environment exists.
envid_t
ipc_find_env(enum EnvType type)
{
  8022ae:	f3 0f 1e fb          	endbr32 
  8022b2:	55                   	push   %ebp
  8022b3:	89 e5                	mov    %esp,%ebp
  8022b5:	8b 4d 08             	mov    0x8(%ebp),%ecx
	int i;
	for (i = 0; i < NENV; i++)
  8022b8:	b8 00 00 00 00       	mov    $0x0,%eax
		if (envs[i].env_type == type)
  8022bd:	6b d0 7c             	imul   $0x7c,%eax,%edx
  8022c0:	81 c2 00 00 c0 ee    	add    $0xeec00000,%edx
  8022c6:	8b 52 50             	mov    0x50(%edx),%edx
  8022c9:	39 ca                	cmp    %ecx,%edx
  8022cb:	74 11                	je     8022de <ipc_find_env+0x30>
	for (i = 0; i < NENV; i++)
  8022cd:	83 c0 01             	add    $0x1,%eax
  8022d0:	3d 00 04 00 00       	cmp    $0x400,%eax
  8022d5:	75 e6                	jne    8022bd <ipc_find_env+0xf>
			return envs[i].env_id;
	return 0;
  8022d7:	b8 00 00 00 00       	mov    $0x0,%eax
  8022dc:	eb 0b                	jmp    8022e9 <ipc_find_env+0x3b>
			return envs[i].env_id;
  8022de:	6b c0 7c             	imul   $0x7c,%eax,%eax
  8022e1:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  8022e6:	8b 40 48             	mov    0x48(%eax),%eax
}
  8022e9:	5d                   	pop    %ebp
  8022ea:	c3                   	ret    

008022eb <pageref>:
#include <inc/lib.h>

int
pageref(void *v)
{
  8022eb:	f3 0f 1e fb          	endbr32 
  8022ef:	55                   	push   %ebp
  8022f0:	89 e5                	mov    %esp,%ebp
  8022f2:	8b 45 08             	mov    0x8(%ebp),%eax
	pte_t pte;

	if (!(uvpd[PDX(v)] & PTE_P))
  8022f5:	89 c2                	mov    %eax,%edx
  8022f7:	c1 ea 16             	shr    $0x16,%edx
  8022fa:	8b 0c 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%ecx
		return 0;
  802301:	ba 00 00 00 00       	mov    $0x0,%edx
	if (!(uvpd[PDX(v)] & PTE_P))
  802306:	f6 c1 01             	test   $0x1,%cl
  802309:	74 1c                	je     802327 <pageref+0x3c>
	pte = uvpt[PGNUM(v)];
  80230b:	c1 e8 0c             	shr    $0xc,%eax
  80230e:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
	if (!(pte & PTE_P))
  802315:	a8 01                	test   $0x1,%al
  802317:	74 0e                	je     802327 <pageref+0x3c>
		return 0;
	return pages[PGNUM(pte)].pp_ref;
  802319:	c1 e8 0c             	shr    $0xc,%eax
  80231c:	0f b7 14 c5 04 00 00 	movzwl -0x10fffffc(,%eax,8),%edx
  802323:	ef 
  802324:	0f b7 d2             	movzwl %dx,%edx
}
  802327:	89 d0                	mov    %edx,%eax
  802329:	5d                   	pop    %ebp
  80232a:	c3                   	ret    
  80232b:	66 90                	xchg   %ax,%ax
  80232d:	66 90                	xchg   %ax,%ax
  80232f:	90                   	nop

00802330 <__udivdi3>:
  802330:	f3 0f 1e fb          	endbr32 
  802334:	55                   	push   %ebp
  802335:	57                   	push   %edi
  802336:	56                   	push   %esi
  802337:	53                   	push   %ebx
  802338:	83 ec 1c             	sub    $0x1c,%esp
  80233b:	8b 54 24 3c          	mov    0x3c(%esp),%edx
  80233f:	8b 6c 24 30          	mov    0x30(%esp),%ebp
  802343:	8b 74 24 34          	mov    0x34(%esp),%esi
  802347:	8b 5c 24 38          	mov    0x38(%esp),%ebx
  80234b:	85 d2                	test   %edx,%edx
  80234d:	75 19                	jne    802368 <__udivdi3+0x38>
  80234f:	39 f3                	cmp    %esi,%ebx
  802351:	76 4d                	jbe    8023a0 <__udivdi3+0x70>
  802353:	31 ff                	xor    %edi,%edi
  802355:	89 e8                	mov    %ebp,%eax
  802357:	89 f2                	mov    %esi,%edx
  802359:	f7 f3                	div    %ebx
  80235b:	89 fa                	mov    %edi,%edx
  80235d:	83 c4 1c             	add    $0x1c,%esp
  802360:	5b                   	pop    %ebx
  802361:	5e                   	pop    %esi
  802362:	5f                   	pop    %edi
  802363:	5d                   	pop    %ebp
  802364:	c3                   	ret    
  802365:	8d 76 00             	lea    0x0(%esi),%esi
  802368:	39 f2                	cmp    %esi,%edx
  80236a:	76 14                	jbe    802380 <__udivdi3+0x50>
  80236c:	31 ff                	xor    %edi,%edi
  80236e:	31 c0                	xor    %eax,%eax
  802370:	89 fa                	mov    %edi,%edx
  802372:	83 c4 1c             	add    $0x1c,%esp
  802375:	5b                   	pop    %ebx
  802376:	5e                   	pop    %esi
  802377:	5f                   	pop    %edi
  802378:	5d                   	pop    %ebp
  802379:	c3                   	ret    
  80237a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  802380:	0f bd fa             	bsr    %edx,%edi
  802383:	83 f7 1f             	xor    $0x1f,%edi
  802386:	75 48                	jne    8023d0 <__udivdi3+0xa0>
  802388:	39 f2                	cmp    %esi,%edx
  80238a:	72 06                	jb     802392 <__udivdi3+0x62>
  80238c:	31 c0                	xor    %eax,%eax
  80238e:	39 eb                	cmp    %ebp,%ebx
  802390:	77 de                	ja     802370 <__udivdi3+0x40>
  802392:	b8 01 00 00 00       	mov    $0x1,%eax
  802397:	eb d7                	jmp    802370 <__udivdi3+0x40>
  802399:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  8023a0:	89 d9                	mov    %ebx,%ecx
  8023a2:	85 db                	test   %ebx,%ebx
  8023a4:	75 0b                	jne    8023b1 <__udivdi3+0x81>
  8023a6:	b8 01 00 00 00       	mov    $0x1,%eax
  8023ab:	31 d2                	xor    %edx,%edx
  8023ad:	f7 f3                	div    %ebx
  8023af:	89 c1                	mov    %eax,%ecx
  8023b1:	31 d2                	xor    %edx,%edx
  8023b3:	89 f0                	mov    %esi,%eax
  8023b5:	f7 f1                	div    %ecx
  8023b7:	89 c6                	mov    %eax,%esi
  8023b9:	89 e8                	mov    %ebp,%eax
  8023bb:	89 f7                	mov    %esi,%edi
  8023bd:	f7 f1                	div    %ecx
  8023bf:	89 fa                	mov    %edi,%edx
  8023c1:	83 c4 1c             	add    $0x1c,%esp
  8023c4:	5b                   	pop    %ebx
  8023c5:	5e                   	pop    %esi
  8023c6:	5f                   	pop    %edi
  8023c7:	5d                   	pop    %ebp
  8023c8:	c3                   	ret    
  8023c9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  8023d0:	89 f9                	mov    %edi,%ecx
  8023d2:	b8 20 00 00 00       	mov    $0x20,%eax
  8023d7:	29 f8                	sub    %edi,%eax
  8023d9:	d3 e2                	shl    %cl,%edx
  8023db:	89 54 24 08          	mov    %edx,0x8(%esp)
  8023df:	89 c1                	mov    %eax,%ecx
  8023e1:	89 da                	mov    %ebx,%edx
  8023e3:	d3 ea                	shr    %cl,%edx
  8023e5:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  8023e9:	09 d1                	or     %edx,%ecx
  8023eb:	89 f2                	mov    %esi,%edx
  8023ed:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  8023f1:	89 f9                	mov    %edi,%ecx
  8023f3:	d3 e3                	shl    %cl,%ebx
  8023f5:	89 c1                	mov    %eax,%ecx
  8023f7:	d3 ea                	shr    %cl,%edx
  8023f9:	89 f9                	mov    %edi,%ecx
  8023fb:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  8023ff:	89 eb                	mov    %ebp,%ebx
  802401:	d3 e6                	shl    %cl,%esi
  802403:	89 c1                	mov    %eax,%ecx
  802405:	d3 eb                	shr    %cl,%ebx
  802407:	09 de                	or     %ebx,%esi
  802409:	89 f0                	mov    %esi,%eax
  80240b:	f7 74 24 08          	divl   0x8(%esp)
  80240f:	89 d6                	mov    %edx,%esi
  802411:	89 c3                	mov    %eax,%ebx
  802413:	f7 64 24 0c          	mull   0xc(%esp)
  802417:	39 d6                	cmp    %edx,%esi
  802419:	72 15                	jb     802430 <__udivdi3+0x100>
  80241b:	89 f9                	mov    %edi,%ecx
  80241d:	d3 e5                	shl    %cl,%ebp
  80241f:	39 c5                	cmp    %eax,%ebp
  802421:	73 04                	jae    802427 <__udivdi3+0xf7>
  802423:	39 d6                	cmp    %edx,%esi
  802425:	74 09                	je     802430 <__udivdi3+0x100>
  802427:	89 d8                	mov    %ebx,%eax
  802429:	31 ff                	xor    %edi,%edi
  80242b:	e9 40 ff ff ff       	jmp    802370 <__udivdi3+0x40>
  802430:	8d 43 ff             	lea    -0x1(%ebx),%eax
  802433:	31 ff                	xor    %edi,%edi
  802435:	e9 36 ff ff ff       	jmp    802370 <__udivdi3+0x40>
  80243a:	66 90                	xchg   %ax,%ax
  80243c:	66 90                	xchg   %ax,%ax
  80243e:	66 90                	xchg   %ax,%ax

00802440 <__umoddi3>:
  802440:	f3 0f 1e fb          	endbr32 
  802444:	55                   	push   %ebp
  802445:	57                   	push   %edi
  802446:	56                   	push   %esi
  802447:	53                   	push   %ebx
  802448:	83 ec 1c             	sub    $0x1c,%esp
  80244b:	8b 44 24 3c          	mov    0x3c(%esp),%eax
  80244f:	8b 74 24 30          	mov    0x30(%esp),%esi
  802453:	8b 5c 24 34          	mov    0x34(%esp),%ebx
  802457:	8b 7c 24 38          	mov    0x38(%esp),%edi
  80245b:	85 c0                	test   %eax,%eax
  80245d:	75 19                	jne    802478 <__umoddi3+0x38>
  80245f:	39 df                	cmp    %ebx,%edi
  802461:	76 5d                	jbe    8024c0 <__umoddi3+0x80>
  802463:	89 f0                	mov    %esi,%eax
  802465:	89 da                	mov    %ebx,%edx
  802467:	f7 f7                	div    %edi
  802469:	89 d0                	mov    %edx,%eax
  80246b:	31 d2                	xor    %edx,%edx
  80246d:	83 c4 1c             	add    $0x1c,%esp
  802470:	5b                   	pop    %ebx
  802471:	5e                   	pop    %esi
  802472:	5f                   	pop    %edi
  802473:	5d                   	pop    %ebp
  802474:	c3                   	ret    
  802475:	8d 76 00             	lea    0x0(%esi),%esi
  802478:	89 f2                	mov    %esi,%edx
  80247a:	39 d8                	cmp    %ebx,%eax
  80247c:	76 12                	jbe    802490 <__umoddi3+0x50>
  80247e:	89 f0                	mov    %esi,%eax
  802480:	89 da                	mov    %ebx,%edx
  802482:	83 c4 1c             	add    $0x1c,%esp
  802485:	5b                   	pop    %ebx
  802486:	5e                   	pop    %esi
  802487:	5f                   	pop    %edi
  802488:	5d                   	pop    %ebp
  802489:	c3                   	ret    
  80248a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  802490:	0f bd e8             	bsr    %eax,%ebp
  802493:	83 f5 1f             	xor    $0x1f,%ebp
  802496:	75 50                	jne    8024e8 <__umoddi3+0xa8>
  802498:	39 d8                	cmp    %ebx,%eax
  80249a:	0f 82 e0 00 00 00    	jb     802580 <__umoddi3+0x140>
  8024a0:	89 d9                	mov    %ebx,%ecx
  8024a2:	39 f7                	cmp    %esi,%edi
  8024a4:	0f 86 d6 00 00 00    	jbe    802580 <__umoddi3+0x140>
  8024aa:	89 d0                	mov    %edx,%eax
  8024ac:	89 ca                	mov    %ecx,%edx
  8024ae:	83 c4 1c             	add    $0x1c,%esp
  8024b1:	5b                   	pop    %ebx
  8024b2:	5e                   	pop    %esi
  8024b3:	5f                   	pop    %edi
  8024b4:	5d                   	pop    %ebp
  8024b5:	c3                   	ret    
  8024b6:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  8024bd:	8d 76 00             	lea    0x0(%esi),%esi
  8024c0:	89 fd                	mov    %edi,%ebp
  8024c2:	85 ff                	test   %edi,%edi
  8024c4:	75 0b                	jne    8024d1 <__umoddi3+0x91>
  8024c6:	b8 01 00 00 00       	mov    $0x1,%eax
  8024cb:	31 d2                	xor    %edx,%edx
  8024cd:	f7 f7                	div    %edi
  8024cf:	89 c5                	mov    %eax,%ebp
  8024d1:	89 d8                	mov    %ebx,%eax
  8024d3:	31 d2                	xor    %edx,%edx
  8024d5:	f7 f5                	div    %ebp
  8024d7:	89 f0                	mov    %esi,%eax
  8024d9:	f7 f5                	div    %ebp
  8024db:	89 d0                	mov    %edx,%eax
  8024dd:	31 d2                	xor    %edx,%edx
  8024df:	eb 8c                	jmp    80246d <__umoddi3+0x2d>
  8024e1:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  8024e8:	89 e9                	mov    %ebp,%ecx
  8024ea:	ba 20 00 00 00       	mov    $0x20,%edx
  8024ef:	29 ea                	sub    %ebp,%edx
  8024f1:	d3 e0                	shl    %cl,%eax
  8024f3:	89 44 24 08          	mov    %eax,0x8(%esp)
  8024f7:	89 d1                	mov    %edx,%ecx
  8024f9:	89 f8                	mov    %edi,%eax
  8024fb:	d3 e8                	shr    %cl,%eax
  8024fd:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  802501:	89 54 24 04          	mov    %edx,0x4(%esp)
  802505:	8b 54 24 04          	mov    0x4(%esp),%edx
  802509:	09 c1                	or     %eax,%ecx
  80250b:	89 d8                	mov    %ebx,%eax
  80250d:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  802511:	89 e9                	mov    %ebp,%ecx
  802513:	d3 e7                	shl    %cl,%edi
  802515:	89 d1                	mov    %edx,%ecx
  802517:	d3 e8                	shr    %cl,%eax
  802519:	89 e9                	mov    %ebp,%ecx
  80251b:	89 7c 24 0c          	mov    %edi,0xc(%esp)
  80251f:	d3 e3                	shl    %cl,%ebx
  802521:	89 c7                	mov    %eax,%edi
  802523:	89 d1                	mov    %edx,%ecx
  802525:	89 f0                	mov    %esi,%eax
  802527:	d3 e8                	shr    %cl,%eax
  802529:	89 e9                	mov    %ebp,%ecx
  80252b:	89 fa                	mov    %edi,%edx
  80252d:	d3 e6                	shl    %cl,%esi
  80252f:	09 d8                	or     %ebx,%eax
  802531:	f7 74 24 08          	divl   0x8(%esp)
  802535:	89 d1                	mov    %edx,%ecx
  802537:	89 f3                	mov    %esi,%ebx
  802539:	f7 64 24 0c          	mull   0xc(%esp)
  80253d:	89 c6                	mov    %eax,%esi
  80253f:	89 d7                	mov    %edx,%edi
  802541:	39 d1                	cmp    %edx,%ecx
  802543:	72 06                	jb     80254b <__umoddi3+0x10b>
  802545:	75 10                	jne    802557 <__umoddi3+0x117>
  802547:	39 c3                	cmp    %eax,%ebx
  802549:	73 0c                	jae    802557 <__umoddi3+0x117>
  80254b:	2b 44 24 0c          	sub    0xc(%esp),%eax
  80254f:	1b 54 24 08          	sbb    0x8(%esp),%edx
  802553:	89 d7                	mov    %edx,%edi
  802555:	89 c6                	mov    %eax,%esi
  802557:	89 ca                	mov    %ecx,%edx
  802559:	0f b6 4c 24 04       	movzbl 0x4(%esp),%ecx
  80255e:	29 f3                	sub    %esi,%ebx
  802560:	19 fa                	sbb    %edi,%edx
  802562:	89 d0                	mov    %edx,%eax
  802564:	d3 e0                	shl    %cl,%eax
  802566:	89 e9                	mov    %ebp,%ecx
  802568:	d3 eb                	shr    %cl,%ebx
  80256a:	d3 ea                	shr    %cl,%edx
  80256c:	09 d8                	or     %ebx,%eax
  80256e:	83 c4 1c             	add    $0x1c,%esp
  802571:	5b                   	pop    %ebx
  802572:	5e                   	pop    %esi
  802573:	5f                   	pop    %edi
  802574:	5d                   	pop    %ebp
  802575:	c3                   	ret    
  802576:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  80257d:	8d 76 00             	lea    0x0(%esi),%esi
  802580:	29 fe                	sub    %edi,%esi
  802582:	19 c3                	sbb    %eax,%ebx
  802584:	89 f2                	mov    %esi,%edx
  802586:	89 d9                	mov    %ebx,%ecx
  802588:	e9 1d ff ff ff       	jmp    8024aa <__umoddi3+0x6a>
